VBA Macro Create Unique Combination of items from a few lists (n factorial)

jeunemec

New Member
Joined
Feb 25, 2014
Messages
1
To all of you VBA experts out there, I have a couple of excel tasks (n factorial) that might perhaps be fairly simple to do with VBA: task 2 is the ideal but task1 will be fine as well. So I have 3 columns, and each column has 2 or more items in them. Task 1: How can I create a unique combination of all the items from each of the 3 columns and output that into 3 new columns ( in the same sheet or another sheet). For example, my 3 columns are 3 lists for Color( green, red, yellow, blue) , Country ( USA, Spain) and Rank( 1,2,3,4 5). So for example, the output first row could be Green, USA, 1 or Red, Spain, 4, etc… Task2: Maybe slightly more complex but great if it can be done, how can I offer a user the option to pick the lists (i,e Color, country, state, rank, year…) but also the option to pick which items to include in each list they pick? Suppose in your sheet1, you have 5 columns for Color, country, state, rank, year that have 2 or more items in each of them. These are possible steps for example: a) A MsgBox called “Create Unique Combination of Lists”. When you click on it, then b) A MsgBox for the first list appears “ choose your colors” and it will display all available colors that can be chosen from with a checkbox. Then c) A MsgBox for the second list appears “ choose your countries” and it will display all available countries that can be chosen from with a checkbox. And so forth for the remaining lists. d) Finally, the output of the unique combination of items in each list will outputted into another sheet with column headers Color, Country, state, rank, year Let me know if you need more clarification and thanks a bunch!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,216,090
Messages
6,128,765
Members
449,467
Latest member
sdafasfasdf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top