Jugulator
8/15/2018 - 11:59 AM

Find Item In String Array

Function FindItemInStringArray(arr As Variant, str As String) As Boolean
'Description:   looks for a string in a string array
'Inputs:        array to look in; string to search
'Output:        true if found, false if not found or error occured

Dim i As Integer

'   Default value
    FindItemInStringArray = False

'   Check arr is array
    If IsArray(arr) = False Then Exit Function
'   Check arr is not empty
    If IsArrayEmpty(arr) = True Then Exit Function

    For i = LBound(arr) To UBound(arr)
        If StrComp(arr(i), str, vbTextCompare) = 0 Then
            FindItemInStringArray = True
            Exit Function
        End If
    Next i
    
End Function