Excel VBA combinations for 2,3,4,5 or 6 numbers

Eager_For_Knowledge

New Member
Joined
Sep 2, 2014
Messages
5
I'm trying to create the combination list of 2,3,4,5 or 6 numbers depending on what is required. For instance in cell(1,1) i put 6, in cell(1,2) i put 3, in cell(1,3) i put 4, then macro would produce the combination list of the 3 numbers listed and so on. i want the combination results to be listed in ColumnA, delimited like 1-12-24-5. if or when the combination results reach row 1048576, i want it to move to ColumnB when rows reach 1048576 move to ColumnC and so on, until the combination is complete. I'm new to VBA and need help.

Example:

ColumnA ColumnB ColumnC ColumnD ColumnE ColumnF ColumnG
2 Enter number here: 5 2 10 8 1
3 Results:
4 5-2-10-8-1
5 2-5-10-8-1
6 10-8-5-2-1
7
8



1048576 8-10-5-1-2
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
There's a workbook at https://app.box.com/shared/f3puhccnqa that will do this:

B​
C​
7​
m​
1 2 5 8 10
8​
5​
10 8 5 2 1
9​
5​
10 8 5 1 2
10​
5​
10 8 2 5 1
11​
5​
10 8 2 1 5
12​
5​
10 8 1 5 2
13​
5​
10 8 1 2 5
14​
5​
10 5 8 2 1
15​
5​
10 5 8 1 2
16​
5​
10 5 2 8 1
17​
5​
10 5 2 1 8
18​
5​
10 5 1 8 2
19​
5​
10 5 1 2 8
20​
5​
10 2 8 5 1
21​
5​
10 2 8 1 5
22​
5​
10 2 5 8 1
23​
5​
10 2 5 1 8
24​
5​
10 2 1 8 5
25​
5​
10 2 1 5 8
26​
5​
10 1 8 5 2
27​
5​
10 1 8 2 5
28​
5​
10 1 5 8 2
29​
5​

It won't do more than one column.
 
Upvote 0
There's a workbook at https://app.box.com/shared/f3puhccnqa that will do this:

B​
C​
7​
m​
1 2 5 8 10
8​
5​
10 8 5 2 1
9​
5​
10 8 5 1 2
10​
5​
10 8 2 5 1
11​
5​
10 8 2 1 5
12​
5​
10 8 1 5 2
13​
5​
10 8 1 2 5
14​
5​
10 5 8 2 1
15​
5​
10 5 8 1 2
16​
5​
10 5 2 8 1
17​
5​
10 5 2 1 8
18​
5​
10 5 1 8 2
19​
5​
10 5 1 2 8
20​
5​
10 2 8 5 1
21​
5​
10 2 8 1 5
22​
5​
10 2 5 8 1
23​
5​
10 2 5 1 8
24​
5​
10 2 1 8 5
25​
5​
10 2 1 5 8
26​
5​
10 1 8 5 2
27​
5​
10 1 8 2 5
28​
5​
10 1 5 8 2
29​
5​

<tbody>
</tbody>


It won't do more than one column.


This is exactly what is wanted. Thank you. Is there by any chance a PERMUTATION version to this exact thing that will take into consideration excel row limit of 1048576 and move to the next column and continue permutation until it is finished?
 
Upvote 0
This is brilliant work my friend, just brilliant its exactly what i wanted. Thank you.

Is there by any chance a PERMUTATION version to this exact thing that will take into consideration that each number is between 1-35 and excel row limit of 1048576 which moves to the next column and continue permutation until it is finished?
 
Upvote 0
Does anyone have a macro that reads 7 numbers and creates a list of all combinations of 5? I'd need to type the 7 numbers each time and then run the macro. Can anyone help? Thanks
John
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,830
Members
449,190
Latest member
rscraig11

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