Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Finding elements in a collection

Hi
There is nothing like union, intersection, in, not in or any set
properties for collections.
To test if something is in a collection you must
1. Make sure each element has a unique key when you add it
2. To test if a particular key is in the collection do
Err.Clear
On error resume next
myCollection.Add Item, ItemKey
If err.number<0 then
msgbox "Sorry, item " & ItemKey & " is in the collection"
end if
on error goto 0

Unfortunately, this adds the testing item to the collection, so you
must be sure it is the same as the original item with that key. If not,
you will need two collections - a real one and a testing one!

Does anyone out there have a custom Collection Class which has set like
properties?
regards
Paul
J Streger wrote:

I was told that you can use the 'in' command to see if a particular element
exists in a collection, but cannot figure out how to do it, and now I'm
skeptical it exists as a function. They described it as:

if strElement in colNames then
...

but this generates a syntax error, and help has no topics i can find. Can
anyone shed light on this? Also does a collection have a function like Join?
Thanks.

--
*********************
J Streger
MS Office Master 2000 ed.
MS Project White Belt 2003


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
series objects; finding specific ones in the collection cate Charts and Charting in Excel 2 April 4th 10 03:25 PM
Finding all elements in a database Lady Success Excel Discussion (Misc queries) 1 May 7th 09 06:01 AM
Finding elements in a collection Chip Pearson Excel Programming 1 January 11th 07 11:38 PM
Finding duplicated elements in a list M.A.A.C Excel Discussion (Misc queries) 2 November 23rd 06 12:13 PM
Finding the elements of the sum Jüri Kuusik Excel Programming 1 September 30th 03 05:19 PM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"