A
Alex Lee
Dear all:
I have newbie question on how to match strings with excel macro.
What I want is to match a word against different elements of an array
and do something with it if matches.
Lets say I have an array like the one below and now I want to output
(msgbox) every time the string "apple" appears. How would I do this?
In perl it would be trivial with something like =~ /.apple./
----------------------------------------------
Dim arr() As Variant
ReDim arr(3)
arr(1) = "apple tree"
arr(2) = "I like apples"
arr(3) = "pears are good for you"
For x = 1 To 3
If arr(x) = "*apple*" Then
msgbox arr(x)
end if
Next
----------------------------------------------
Unfortunenly the code above does not work. Any help?
thanks. alex
I have newbie question on how to match strings with excel macro.
What I want is to match a word against different elements of an array
and do something with it if matches.
Lets say I have an array like the one below and now I want to output
(msgbox) every time the string "apple" appears. How would I do this?
In perl it would be trivial with something like =~ /.apple./
----------------------------------------------
Dim arr() As Variant
ReDim arr(3)
arr(1) = "apple tree"
arr(2) = "I like apples"
arr(3) = "pears are good for you"
For x = 1 To 3
If arr(x) = "*apple*" Then
msgbox arr(x)
end if
Next
----------------------------------------------
Unfortunenly the code above does not work. Any help?
thanks. alex