View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default efficiency qn: search collection or use on error?

Tom..

your code will only return true
if the collection contains objects..

if the collection's items contains values (or arrays)
it will always return false.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote :

Use the key property

MyCollection.Add item:=MyName, key:=MyName

Key must be a string.

then
On error resume next
set obj = MyCollection(MyName)
On error goto 0
if obj is nothing then
msgbox MyName & " not found"
End if