0

I have an array that contains "Hot Soup". When I use the following function in an If statement to test whether "Soup" is found in the array, it returns as true:

Function FindInArray(StringToBeFound As Variant, ThisArray As Variant) As Boolean

  FindInArray = (UBound(Filter(ThisArray, StringToBeFound)) > -1)

End Function

A test:

Sub Test()

    Dim bool As Boolean

    myArray = Array("Hot Soup", "Vanilla")
    bool = FindInArray("Soup", myArray)
    MsgBox bool

End Sub

This returns true, and it is not. Is there a way to return true ONLY if the match is exact?

Thanks!

0 Answers0