Excel VBA like operator

excel, string, vba

Solution

The `Like` operator is already available in VBA:

If "I am studying at University of Texas at Arlington" Like "*Univ*of*Texas*" Then
    MsgBox "Yes, it is!"
End If

Problem

I am using excel VBA to search for a substring in another string as below. ``` Dim pos As Integer pos = InStr("I am studying at University of Texas at Arlington", "University of Texas") ``` If `pos` returns a non-negative value, it means I have the substring in the string. However, I need a more sophisticated search, where the substring can be "Univ of Tex": ``` InStr("I am studying at University of Texas at Arlington", "Univ of Tex") ``` Doesn't work for that. Based on the maximum search terms, I need to say the substring is present. Is it possible using excel VBA?

Original source