I have two loops going through rows and columns in excel with a large if or statement checking if there's a certain string in one of the columns. However, even though I've added Option Compare Text
to get rid of case sensitivity, sometimes my code will skip over columns even if they have the specified text in them.
Right now, my statement looks like this:
If worksheet.Cells(j, i).Text="text" or worksheet.Cells(j, i).Text = "other text"...
I figured it could be that spaces are causing the problem, but after testing, it seems arbitrary. Is there something wrong with my If statement, or is there possibly something else in the excel sheets it's not working on that I haven't covered? (Like text being italicized or bold).
For the record, I'm not using like
or instr
because some of the columns may contain pieces of the string but may not be what I'm looking for.