Hi
I currently have 2 macros set up to search a sheet for different words and delete the row if that word is present.
I would like to combine these into a single macro which would check for both words and delete the row if either of them are present
The words are in different columns
I search for the word "resident" in column G with this
And I then search for the word "Limited" in Column H using this
What's the best way to combine these 2 into a single macro to search for both?
Thank you
Colin
I currently have 2 macros set up to search a sheet for different words and delete the row if that word is present.
I would like to combine these into a single macro which would check for both words and delete the row if either of them are present
The words are in different columns
I search for the word "resident" in column G with this
' Delete Any resident stores
Dim ws As Worksheet
Dim strSearch As String
Dim lRow As Long
strSearch = "Resident"
Set ws = Sheets("Site data")
With ws
lRow = .Range("G" & .Rows.Count).End(xlUp).Row
'~~> Remove any filters
.AutoFilterMode = False
'~~> Filter, offset(to exclude headers) and delete visible rows
With .Range("G1:G" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
And I then search for the word "Limited" in Column H using this
Dim ws As Worksheet
Dim strSearch As String
Dim lRow As Long
strSearch = "Limited"
Set ws = Sheets("Site data")
With ws
lRow = .Range("H" & .Rows.Count).End(xlUp).Row
'~~> Remove any filters
.AutoFilterMode = False
'~~> Filter, offset(to exclude headers) and delete visible rows
With .Range("H1:H" & lRow)
.AutoFilter Field:=1, Criteria1:="=*" & strSearch & "*"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
What's the best way to combine these 2 into a single macro to search for both?
Thank you
Colin