Reputation: 323
So I have
Dim str1
str1 = "Cat"
Dim str2
str2 = "concatenate"
I wanted to know is there a way I can match str1 with str2 and return positive non-zero number if there is match (case-insensitive) for str1 in str2 ?
Upvotes: 0
Views: 8716
Reputation: 5426
Use instr or instrrev:
instr(str2, str1, 1)
See msdn for more info. This does exactly what you need.
Upvotes: 0
Reputation: 152605
For VBA, The instr is the way to go:
InStr(1, str2, str1, vbTextCompare)
The first part is where it starts looking, in this case the first character.
The second is the string in which the search is happening.
The third is the search parameter.
The fourth determines whether it looks at the text of the binary value. So for a case-insensitive we use vbtextcompare.
Upvotes: 3