
exact matches in an array
Here's one way.
You'll have to consider including LCase or UCase if you want eg Monday = monday
daysarray= array("Monday","Tuesday","Wednesday")
temp = "~" & join(daysarray,"~") & "~"
if instr(temp,"~day~") > 0 then msgbox "found": _
else msgbox "not in array... go ahead and add it"
--
Regards
Michael Dunn
: Is there a way just to check if there is an exact match in
: an array without having to loop through the entire array?
:
: I've tried the Filter function, but that returns substring
: matches too ... I want to be able to check if a value is
: in the array before adding it to make sure there are no
: duplicates in the array.
:
: Here's an example of what I want:
: daysarray= array("Monday","Tuesday","Wednesday")
: ' if I want to add "day", Filter returns all of the above
: ' but "day" is still not in the array
:
: I want something that'll say: nope, "day" is not in the
: array ... go ahead and add it
:
: Thanks!
: Candee