I am confused about this case I came across. I Have a code:
Sub Testing()
Dim UnitArray
UnitArray = Array("Standard", "Jumbo")
Dim Unit As String
Unit = "Standard"
If IsInArray(UnitArray, Unit) Then
MsgBox ("Great success")
End If
End Sub
And a function:
Function IsInArray(arr As Variant, myVal As Variant) As Boolean
Dim mtch
mtch = Application.Match(myVal, arr, True)
If Not IsError(mtch) Then
If mtch = UBound(arr) Then
If arr(UBound(arr)) = myVal Then IsInArray = True: Exit Function
Else
IsInArray = True: Exit Function
End If
End If
IsInArray = False
End Function
If that array has only "Standard" - it works, but else it doesn't find the value. What's the mistake I have made?