When calling the below function in Excel by using =MyVlookup(B1,Sheet1!A:A,1) I get what I want.
Function MyVlookup(Lval As Range, c As Range, oset As Long) As Variant
Dim cl As Range
For Each cl In c.Columns(1).Cells
If UCase(Lval) = UCase(cl) Then
MyVlookup = cl.Offset(, oset - 1)
Exit Function
End If
Next
End Function
But I'd like to use wildcards around B1, e.g. "*"&B1&"*". When I do that I get an error (#ARG!).
I tried using double quotation marks, but it didn't work, either. What should I do to overcome this?
Range
. If you want to pass a string instead then you need to update the parameter type toAs String
If you need wildcard capability you'll also need to useLike
instead of=
– Tim Williams