I've got some code below, that is supposed to be checking if a value is in an Array or not.
Sub test()
vars1 = Array("Examples")
vars2 = Array("Example")
If IsInArray(Range("A1").Value, vars1) Then
x = 1
End If
If IsInArray(Range("A1").Value, vars2) Then
x = 1
End If
End Sub
Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
IsInArray = (UBound(Filter(arr, stringToBeFound)) > -1)
End Function
If the cell A1
contains the word Examples
for some reason both of the IsInArray
detects it as existing for both Arrays when it should only find it existing in the vars1
array
What do I need to change to make my IsInArray
function to make it an exact match?