ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   search data (https://www.excelbanter.com/excel-programming/439336-search-data.html)

Daniel M

search data
 
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.

Gary Keramidas[_3_]

search data
 
search help for find next.

--


Gary Keramidas
Excel 2003


"Daniel M" wrote in message
...
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.



Héctor Miguel

search data
 
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.



Jacob Skaria

search data
 
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

--
Jacob


"Daniel M" wrote:

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.


Daniel M

search data
 
This worked perfectly. I was looking at the .find help but was having
problems with the syntext. Thank you!

"Jacob Skaria" wrote:

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

--
Jacob


"Daniel M" wrote:

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.



All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com