n96radsb
asked on
search for a string in an array
I have an array of strings
now I want to search the array for a specific string or a part of a string. I just want to know where in the array the string is.
thanks in advance
now I want to search the array for a specific string or a part of a string. I just want to know where in the array the string is.
thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim searchstr As String
Dim bFound As Boolean
searchstr = "Fou"
Dim anItem As Variant
listItems = Array("One", "Two", _
"Three", "Four", "Five")
List1.Clear
bFound = False
For Each anItem In listItems
If InStr(1, anItem, searchstr) Then
bFound = True
Exit For
End If
bFound = False
Next
If bFound Then
MsgBox "Found"
Else
MsgBox " Not found"
End If