search data

  • Thread starter Thread starter Daniel M
  • Start date Start date
D

Daniel M

I need to seach a cell range (C2: C last cell) for a specific string. Once
found i need to delete the entire row and continue searching. Can someone
help me with this? Thanks.
 
hi, Daniel !
I need to seach a cell range (C2: C last cell) for a specific string.
Once found i need to delete the entire row and continue searching.
Can someone help me with this? Thanks.

regarding this "specific" string...
- is (upp/low)er case important ?
- is it a start-string, middle-string, end-string ?
- how many do you expect to be found ? (1, 10, 100, 1000, ...)

(just trying to be in "specific" help to you) :D

regards,
hector.
 
Hi Daniel

Try out the below

Sub Macro()
Dim varFound As Range, varSearch As String

varSearch = "jac"

With Range("C2:C" & Cells(Rows.Count, "C").End(xlUp).Row)
Set varFound = .Find(varSearch, LookIn:=xlValues, SearchDirection:=xlPrevious)
Do While Not varFound Is Nothing
varFound.EntireRow.Delete
Set varFound = .Find(varSearch, LookIn:=xlValues, SearchDirection:=xlPrevious)
Loop
End With
End Sub

Check out help on Range.Find and adjust the code
LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart
 
This worked perfectly. I was looking at the .find help but was having
problems with the syntext. Thank you!
 
Back
Top