Please, try understanding the next code:
Sub testEvaluate()
Dim FormatStrokeArray
FormatStrokeArray = Application.Transpose(Evaluate("row(120:300)")) 'create an array as you need (based 1 array)
Debug.Print Join(FormatStrokeArray, "|") 'see the array in Immediate Window
'play here with integers:
Debug.Print IsInArray(FormatStrokeArray, 300) 'it returns true
Debug.Print IsInArray(FormatStrokeArray, 100) 'it returns false
Debug.Print PositionInArray(FormatStrokeArray, 150) 'it returns 31 (the 31th element)
Debug.Print PositionInArray(FormatStrokeArray, 100) 'it returns -1 (no match)
End Sub
Function IsInArray(arr As Variant, myVal As Integer) 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
Function PositionInArray(arr As Variant, myVal As Integer) As Variant
Dim mtch: mtch = Application.Match(myVal, arr, True)
If Not IsError(mtch) Then
If mtch = UBound(arr) Then
If arr(UBound(arr)) = myVal Then PositionInArray = mtch: Exit Function
Else
PositionInArray = mtch: Exit Function
End If
End If
PositionInArray = -1
End Function
If something not clear, please do not hesitate to ask for clarifications.