In a question regarding VBA: Passing multiple values to Instr John Coleman posted a 'Contains' function that accepts multiple search strings that are then fed into Instr to check, this was great for me and works well. However, it required writing a list of the search strings at design time (as far as I can tell), and I wanted to be able to create dynamic lists of search strings gathered from various places on the speadsheet. So in his function I would call it like this;
If Contains(StringToSearch, "Alan", "Betty", "Arthur", True)
and I wanted to be able to call it more like this;
If Contains(StringToSearch, Range("B1:B3"), True)
I then tried to see if I could assemble my entries dynamically and then pass the result to his function but could not do that like this using 2 different methods;
Dim varClasses() As Variant (Method 1)
Dim strClasses() As String (Method 2)
For i = 0 To n
strClasses(i) = Range("C5").Offset(0, i).Value '(Method 1)
varClasses(i) = Range("C5").Offset(0, i).Value '(Method 2)
Next i
If Contains(sEntry, strClasses, True) Then '(Method 1)
If Contains(sEntry, varClasses, True) Then '(Method 2)
MsgBox "Found"
End If
So I want to be able to create a list of search terms that will be accepted by the function to do the multiple word searches. Thanks for reading.