Good point, Rick! So if just looking for the *word* "logo" then the VBA code
would be:
If InStr(1, Cells(iRow, 1), " logo ", vbTextCompare) 0 Then
Rows(iRow).Delete
End If
Is this correct, putting a space before and after the word?
Toby
"Rick Rothstein (MVP -
VB)" wrote:
I'll clarify my problem. I have hundreds of rows of data with the word
"logo"
nested within other text in a cell. I need a macro to delete those rows.
The
following will delete rows if the ENTIRE text in the cell matches the text
in
quotes in this statement:
If Cells(iRow, 1) = "Hours of Operation" Then Rows(iRow).Delete
How can I make this work for my problem?
How about this...
If InStr(Cells(iRow, 1), "logo") 0 Then Rows(iRow).Delete
if you want your match to be case sensitive; or this, if you want a case
insensitive match...
If InStr(1, Cells(iRow, 1), "logo", vbTextCompare) 0 Then
Rows(iRow).Delete
**NOTE**
===============
InStr does not have a built-in way of distinguishing whole words. That means
if you search word were, to make it easy, "the", you would find the whole
word "the", but you would also get a match from the word "other" because
"the" is in the middle of it. So you have to be aware of the potential for
your search word to be inside other words which could give you unintended
matches when using InStr.
Rick