Trying to loop through a column, searching for "Total" within cells that also contain other text (e.g., "January Total", "Boston Total", "Office Total", "Company ABC Total"), and deleting entire rows where "Total" is found. Here's what I have (r and rcell are defined as range objects):
Set r = Range(Cells(4, "B"), Cells(LastRow, "B"))
For Each rcell In r
If Not Excel.WorksheetFunction.Search("Total", rcell) = "#VALUE!" Then
Rows(target.Row).Delete
Else
'do nothing
End If
Next
I'm trying to pursue the logic that says, "If the cell doesn't contain 'Total', it will return an error. So, for all the cells that don't return an error, delete the row." My syntax is clearly wrong. I've visited a number of similar questions here on the site and haven't been able to substitute working code.
In standard Excel formulas, this would be an IF(ISERROR(SEARCH(...))...).
Thank you very much for the help.