I would like to use the following code in Excel, what changes have to be made for it to work? Thanks in advance.
Code:
Public Function TestCharMatch1(NbrOfChars, StrSearch As String, strFind As String) As String
'Walks through strFind, NbrofChars at at time, and searches strSearch for a match.
If NbrOfChars > Len(strFind) Then
TestCharMatch1 = "ERROR!"
Exit Function
End If
Dim Pos As Integer
Pos = 1
Do While Pos <= (Len(strFind) - (NbrOfChars - 1))
If InStr(StrSearch, Mid(strFind, Pos, NbrOfChars)) > 0 Then
TestCharMatch1 = "Yes! " & Mid(strFind, Pos, NbrOfChars)
Exit Do
Else
TestCharMatch1 = "Sorry no match!"
End If
Pos = Pos + 1
Loop
End Function
Last edited by a moderator: