Suppose I have made an array in VBA, something like:
ShirtCols = array("red", "beige", "white", "black", "blue")
MyCol = "pink"
I want to see if pink is an acceptable shirt colour as per this array (perhaps representing what I have in my closet right now). I could do:
for i = 0 to 4
if ucase(array(i)) = ucase(MyCol) then
msgbox("Today you are able to wear a " & MyCol & " shirt.")
else
msgbox("There are no " & MyCol & " shirts available to wear.")
end if
next i
But I foresee this being slow and perhaps somewhat cumbersome. I have searched for array and find or lookup and can't find anything on seeing if an array contains any specific element. Is there some sort of function like InStr, but for arrays, that could help me here?
Thanks in advance.
Cheers, Tom
ShirtCols = array("red", "beige", "white", "black", "blue")
MyCol = "pink"
I want to see if pink is an acceptable shirt colour as per this array (perhaps representing what I have in my closet right now). I could do:
for i = 0 to 4
if ucase(array(i)) = ucase(MyCol) then
msgbox("Today you are able to wear a " & MyCol & " shirt.")
else
msgbox("There are no " & MyCol & " shirts available to wear.")
end if
next i
But I foresee this being slow and perhaps somewhat cumbersome. I have searched for array and find or lookup and can't find anything on seeing if an array contains any specific element. Is there some sort of function like InStr, but for arrays, that could help me here?
Thanks in advance.
Cheers, Tom