Search within cell and delete row

selkov

Well-known Member
Joined
Jan 26, 2004
Messages
787
i am trying to search thru a worksheet and if a cell contain a specific text delete the row.
but this does not work.
any ideas?


ss=inbut box ("Search For ?")
sr=inputbox ("What Row ?")

lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr + 1 To 1 Step -1
If (IsNumber(Search(ss, sr)&r),Then Rows(r).EntireRow.Delete
next
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
i am trying to search thru a worksheet and if a cell contain a specific text delete the row.
but this does not work.
any ideas?


ss=inbut box ("Search For ?")
sr=inputbox ("What Row ?")

lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr + 1 To 1 Step -1
If (IsNumber(Search(ss, sr)&r),Then Rows(r).EntireRow.Delete
next
Is there a specific Column where the text you are searching for would be found? If so, what column is it?

Will the text you are searching for be in the cell all by itself or could there be other text in the cell along with it?

If other text could be in the cell, does the text you are searching for have to stand alone (like, say, the word other) or would it be allowed to be embedded along with other text (like, say, the word brotherhood)?
 
Last edited:
Upvote 0
Some times ("other") sometimes (the word br"other"hood). The column is a variable.
 
Upvote 0
Some times ("other") sometimes (the word br"other"hood). The column is a variable.
If you were looking for "other", would finding "brotherhood" be okay or would you want to skip over it and try and keep trying to find "other" as a standalone word?
 
Last edited:
Upvote 0
yes that is ok, in fact preferred.
Uh, given how I posed the question, "yes" is kind of an unclear answer... which is preferred, finding the "word" when it stands alone or finding the "word" even if it is embedded within a larger "word"?
 
Upvote 0
I need to be able to do both.
Okay, just to clarify, if the text the user supplies to the InputBox is found in any cell or cells anywhere on the active worksheet, you want the entire row for that cell or those cells deleted... is that correct?

One other question... will there ever be any formulas located on the worksheet you apply this macro to?
 
Upvote 0
What I need is to search in a specific column and if the text is found delete the row.
As per my failed macro bot the search string anf the search location need to be variables.
 
Upvote 0

Forum statistics

Threads
1,213,568
Messages
6,114,348
Members
448,570
Latest member
rik81h

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top