Reputation: 37
I want to know how to check if nth element of an array in VBA contains certain character - e.g. total content is "My email address is [email protected]" so the array elements would be "My", "email", "address" etc. and one of them would be "[email protected]".
I need to know which element starts with "a." and then print that element of that array.
Upvotes: 0
Views: 64
Reputation: 35408
This should show you the basic idea
Sub ArrayCheck()
Dim myArray(1 To 5) As String
myArray(1) = "My"
myArray(2) = "email"
myArray(3) = "address"
myArray(4) = "[email protected]"
myArray(5) = "some other stuff"
Dim strElement As Variant
For Each strElement In myArray
If strElement Like "a.*" Then
MsgBox "Hit: " & strElement
End If
Next strElement
End Sub
Upvotes: 1