View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
noel mc noel mc is offline
external usenet poster
 
Posts: 3
Default efficiency qn: search collection or use on error?

Hi,

Is it more efficient to explicitly search a collection for an entry
i.e. :

function elementExists(myCollection as collection, myName as string) as
boolean
elementExists = false
for each element in myCollection
if element.name = myName
elementExists = true
exit function
end if
next
end function

*OR* whether it is faster/better to use the name as a collection parameter
to call an item and catch any exceptions? (I'm not familiar with the code
used to implement the latter, but surely it must perform the same kind of
operation as the former...?)

Thanks all