Thread: Collection
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Collection

Todd,

Here is a function to test it

Public Function IfExists(col As Collection, ByVal sKey As String)

On Error GoTo NoSuchKey

If VarType(col.Item(sKey)) = vbObject Then
' force an error condition if key does not exist
End If

IfExists = True

Exit Function

NoSuchKey:
IfExists = False

End Function





--

HTH

RP
(remove nothere from the email address if mailing direct)


"Todd Huttenstine" wrote in message
...
Hey

How do you test to see if a particular value is in a
collection object?

For example, I have a collection with 5 items in it. The
items in it a "abc", "def", "ghi", "jkl", and "mno".
How can I test to see if the value "jkl" is in this
collection, and return true or false?


Thanks
Todd