Reputation: 173
I am comparing two sheets of data. One on sheet, I have a bunch of strings like this: "Apples - are good (YES)" while on the other sheet, I have strings like this "Apples - YES" . in this scenario, the two strings should be compared as the same. When the original data was compiled, there was no naming standard between the two sources. This means that when im using the "like" function, I need it to handle two separate wildcards because there are two parts of the string that need to be compared. What I have right now:
Dim TorF as Boolean
TorF = stringToCompare Like subString1 & "*YES*"
I know my function as a whole is sound, because previously I was only using one wildcard and simply ignoring any strings that contained "-". However, now I actually have to deal with the extra results.
Upvotes: 1
Views: 1122
Reputation: 2556
You can do this by searching the substring1
and "YES"
within your stringToCompare
and proceed with your code when True
:
If InStr(1, stringToCompare, subString1, vbTextCompare) > 0 And InStr(1, stringToCompare, "YES", vbTextCompare) > 0 Then
'your code
End If
Upvotes: 3