All combinations help

Pestomania

Active Member
Joined
May 30, 2018
Messages
332
Office Version
  1. 365
Platform
  1. Windows
Hello, I have 6 columns worth of data (random numbers). How can I get every combination of possibilities? The numbers can be duplicated but once all combinations have been determined, go to next number. I'll out an example.

[TABLE="width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]23[/TD]
[TD]32[/TD]
[TD]49[/TD]
[TD]53[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]50[/TD]
[TD]54[/TD]
[TD]20[/TD]
[TD]29[/TD]
[TD]64[/TD]
[/TR]
</tbody>[/TABLE]

So possible combinations are 1, 23, 32, 49, 53, 12 & 1, 50, 54, 20, 29, 64 & 2, 23, 54, 49, 29, 64.

But I need all combinations of these numbers.

I actually have about 30 rows for each column.

Thank you!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The number of combinations of 30 rows taken 6 at a time is 593775
The number of permutations of 30 rows taken 6 at a time is 427518000
is this your expected output?
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
</body>1, 23, 32, 49, 53, 12
1, 50, 54, 20, 29, 64
2, 23, 54, 49, 29, 64.
2, 50, 54, 20, 29, 64
Ravi shankar
 
Upvote 0
The number of combinations of 30 rows taken 6 at a time is 593775
The number of permutations of 30 rows taken 6 at a time is 427518000
is this your expected output?
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
</body>1, 23, 32, 49, 53, 12
1, 50, 54, 20, 29, 64
2, 23, 54, 49, 29, 64.
2, 50, 54, 20, 29, 64
Ravi shankar

Hello,

Thank you for your reply but I don't believe so. I need Excel to list every combination available. Not the total number possible.

Each number must stay in their respective columns, but would list out all combinations possible.
 
Upvote 0
Hi
try the following codes
Sub pestomania()
Dim a As Integer, b As Integer, c As Integer, d As Integer, e As Integer, x As Integer, y As Integer
c = 1
x = Cells(Rows.Count, 1).End(xlUp).Row
y = Cells(1, Columns.Count).End(xlToLeft).Column
MsgBox "there are " & x & " rows and " & y & " columns"
For a = 1 To y
For b = 1 To x
For d = 1 To x
For e = 1 To y
Cells(c, 10 + a) = Cells(d, a)
Cells(c, 10 + e) = Cells(b, e)
Next e
c = c + 1
Next d
Next b
Next a
MsgBox "complete"
End Sub
It lists 50 x 50 x 6 = 15,000 possible combinations.
ravishankar
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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