Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Intersecting/Unioning Collections


Is there a one-liner (I'll consider a two-liner for half
price) in VBA that takes two or more collections and forms
their intersection or union?

I know about the Intersect and Union methods, but those
only take ranges as arguments; I'm interested in forming
intersections and unions of collections in general. E.g.,
if X, Y, and Z have been declared as New Collection, I've
added objects to both X and Y, and now I want to quickly
set Z equal to the collection that consists of those
objects that are members of both X and Y.

Thanks,

Robbie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Intersecting/Unioning Collections

No there isn't.

no fee for that.

--
Regards,
Tom Ogilvy

Robbie wrote in message
...

Is there a one-liner (I'll consider a two-liner for half
price) in VBA that takes two or more collections and forms
their intersection or union?

I know about the Intersect and Union methods, but those
only take ranges as arguments; I'm interested in forming
intersections and unions of collections in general. E.g.,
if X, Y, and Z have been declared as New Collection, I've
added objects to both X and Y, and now I want to quickly
set Z equal to the collection that consists of those
objects that are members of both X and Y.

Thanks,

Robbie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Intersecting/Unioning Collections

There's nothing built in, but I could send you a sorted list class that
supports set operations. It will handle the basic data types in VBA
(e.g. integers, longs, singles, doubles, strings and variants) but not
more complicated or user-defined object. Let me know if you want to try it.

Dave Ring

Robbie wrote:
Is there a one-liner (I'll consider a two-liner for half
price) in VBA that takes two or more collections and forms
their intersection or union?

I know about the Intersect and Union methods, but those
only take ranges as arguments; I'm interested in forming
intersections and unions of collections in general. E.g.,
if X, Y, and Z have been declared as New Collection, I've
added objects to both X and Y, and now I want to quickly
set Z equal to the collection that consists of those
objects that are members of both X and Y.

Thanks,

Robbie


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Intersecting/Unioning Collections

Don't know if this will help. A "Collection" can't help much with 1-Liners.
However a Dictionary often can.
Here is a quick idea. This has a vba reference set to Microsoft Scripting.

Sub Demo()
'//Dana DeLouis

Dim v1 As New Dictionary
Dim v2 As New Dictionary
Dim rng As Range

Set rng = [B1:C10]
v1.Add rng.Address, rng

Set rng = [E1:F10]
v1.Add rng.Address, rng

Set rng = [A5:J6]
v2.Add rng.Address, rng

Set rng = [A8:J9]
v2.Add rng.Address, rng

'// Here is your 1-Liner :)

Intersect(Range(Join(v1.Keys, ",")), Range(Join(v2.Keys, ","))).Select
End Sub

HTH
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Robbie" wrote in message
...

Is there a one-liner (I'll consider a two-liner for half
price) in VBA that takes two or more collections and forms
their intersection or union?

I know about the Intersect and Union methods, but those
only take ranges as arguments; I'm interested in forming
intersections and unions of collections in general. E.g.,
if X, Y, and Z have been declared as New Collection, I've
added objects to both X and Y, and now I want to quickly
set Z equal to the collection that consists of those
objects that are members of both X and Y.

Thanks,

Robbie



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
how do i create chart like branch-sector sales & collections Gnana Prasad Excel Discussion (Misc queries) 1 January 11th 08 08:00 AM
minimize the file size in a ppt with collections of many pivot tables chermaine Excel Discussion (Misc queries) 1 December 30th 05 11:04 AM
Creating Collections 'on the fly' Dave Peterson[_3_] Excel Programming 4 September 6th 03 07:20 AM
Value at Intersecting cells Wild Bill[_2_] Excel Programming 0 August 28th 03 04:29 AM
Value at Intersecting cells Leo Heuser[_2_] Excel Programming 0 August 27th 03 02:09 PM


All times are GMT +1. The time now is 04:53 PM.

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

About Us

"It's about Microsoft Excel"