Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel: VBA Routine To List Table Of Combinations

Posted on 2011-02-22
9
Medium Priority
?
682 Views
Last Modified: 2012-05-11
Given the following input data (cells L8:Q8): 1, 1, 2, 1, 5, 3
I would like a VBA routine to list all combinations in a table beginning at cell S8, as follows:
1      1      1      1      1      1
1      1      1      1      1      2
1      1      1      1      1      3
1      1      1      1      1      1,2
1      1      1      1      1      1,3
1      1      1      1      1      2,3
1      1      1      1      1      1,2,3
1      1      2      1      1      1
1      1      2      1      1      2
1      1      2      1      1      3
1      1      2      1      1      1,2
1      1      2      1      1      1,3
1      1      2      1      1      2,3
1      1      2      1      1      1,2,3
...

Please advise?

Best wishes,

John
0
Comment
Question by:jfdinneen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 20

Expert Comment

by:Ardhendu Sarangi
ID: 34954222
can you attach a file? your question doesn't seem too clear as to what do you want in Column S.
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34954278
Can you elaborate, don't really follow what you are doing?
0
 

Author Comment

by:jfdinneen
ID: 34954663
As requested...

Best wishes,

John
 EE-Q-26839515.xlsm
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Ardhendu Sarangi
ID: 34954690
Hi,

I am still not getting it... whats the difference between Input, Listing and Combinations? Can you please explain once more? thanks!
0
 

Author Comment

by:jfdinneen
ID: 34954769
For example, under heading 'F', the Input is 3 objects in bin 'F', the Listing is simply the nominal tags of those same objects (1,2,3), and the Combination is the power set (minus empty set) of the listed objects iterated across all power sets of the othe bins ({1} {2} {3} {1,2} {1,3} {2,3} {1,2,3}).

Best wishes,

John
0
 
LVL 4

Accepted Solution

by:
rowanscott earned 2000 total points
ID: 34969560
Hi John

I think this is what you mean (see attached file).  If you copy and paste the code into another workbook you will also need to copy the c_Bin class module.

It took me a while to figure out iterating through the possibilities but it was a good puzzle. Changing the quantity of bins shouldn't be a problem though. It should cope with that fine.

If its not quite what you are after let me know. Or if you want help understanding the class module.

Best regards

Rowan
Demo.xlsm
0
 

Author Closing Comment

by:jfdinneen
ID: 34970706
Thanks Rowan.

Excellent solution. I have a related problem that I will post later today which I would like you to review.

Best wishes,

John
0
 

Author Comment

by:jfdinneen
ID: 34971357
Rowan,

Is it possible to have the listing as per my original question? Also, the related problem is posted as Q26845042.

Best wishes,

John
0
 
LVL 4

Expert Comment

by:rowanscott
ID: 34974152
You'll have to explain that a bit?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question