find a string inside other in VBA

Ricardo Caicedo

New Member
Joined
Aug 21, 2014
Messages
43
I cannot figure out why the function InStr() is not working properly. I know that it does not work with different languages, but in my case is a simple find of a string inside other one.</SPAN>

I have two variables defined in the function as function(DBWord,CustWord)</SPAN>

StrWLow = LCase(DBWord)</SPAN>
StrNLow = LCase(CustWord)</SPAN>

And the part that It is not working is in red…………</SPAN>

If CustNumWords = 1 Then 'Just one word in the customer info</SPAN>
If StrComp(StrWLow, StrNLow, vbTextCompare) = 0 Then</SPAN>
WordMatch = 1</SPAN>
Else</SPAN>
If InStr(1,StrNLow, StrWLow, vbTextCompare) <> 0 Then</SPAN></SPAN>
WordMatch = 1</SPAN>
Else</SPAN>
K = Len(DBWord)</SPAN>
For i = 1 To K</SPAN>
NLetter = Mid(StrWLow, i, 1)</SPAN>
NxLetter = Mid(StrNLow, i, 1)</SPAN>
If NLetter = NxLetter Then</SPAN>
Accura = Accura + (1 / K)</SPAN>
WordMatch = Accura</SPAN>
i = i + 1</SPAN>
Else</SPAN>
i = i + 1</SPAN>
End If</SPAN>

Next i</SPAN>
End If</SPAN>
End If</SPAN>
Else 'more than one word in the customer info</SPAN>
J = 1</SPAN>
L = 1</SPAN>
K = Len(DBWord)</SPAN>
M = Len(CustWord)</SPAN>


End If</SPAN>
Any Help............
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,226,225
Messages
6,189,736
Members
453,566
Latest member
ariestattle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top