How to calculate combinations ?

The Wraith

New Member
Joined
Nov 12, 2005
Messages
12
Hi,
I want to see how much combinations are possible when i got 6 numbers..

-- got this numbers 1--2--3--4--5--6
-- want to calculate how much combinations of ( 2 ) numbers possible
-- want to calculate how much of ( 3 ) numbers possible
-- want to calculate how much of ( 4 ) numbers possible
-- want to calculate how much of ( 5) numbers possible

-- never 2 same numbers together (2-2) or (2-2-3) or (2-2-3-4) may not be in list

-- How can i make the result visible in kind of list ?


I would be nice if somebody knows a good solution..

Greetings

:wink:
 
I have a problem with code:

Run-time error '6':

Overflow

"PopSize = Rng.Cells.Count - 2"

Any advice?

thx
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
This reply may be a bit late but.
Why do you have to hold them on a sheet. Why not process them as they are generated.
 
Upvote 0
Hi,

Is there a way to include duplicates in Myrna's code, ie.
1,1,1
1,1,2
1,1,3...etc...?

I have 144 part list that I need to choose any 3 with duplicates.

Neil
 
Upvote 0
I hope this is the version selection you want. These are not combinations but ordered arrangements.
Try the code below with whatever adjustments you should need.
Code:
Private Sub CommandButton1_Click()
    doit
End Sub
Sub doit()
    Columns("d:l").Clear
    outrow = 0
    outcol = 8
    cc = 0
    upto = 14
    rr = 4
    For x1 = 1 To upto
        For x2 = x1 To upto
            For x3 = x2 To upto
                ' for just the numbers
                outrow = outrow + 1
                Cells(outrow, 5) = x1
                Cells(outrow, 6) = x2
                Cells(outrow, 7) = x3
                ' or if parts are listed down column a
                'starting at row  rr+1
                Cells(outrow, 8) = Cells(x1 + rr, 1)
                Cells(outrow, 9) = Cells(x2 + rr, 1)
                Cells(outrow, 10) = Cells(x3 + rr, 1)
                ' when you change the upto above to 144  there are 508080 of these
                ' so if you want to list them rather than process  as you go
                ' you will need a lines like
               ' If outrow > 60000 Then
                '    outcol = outcol + 4
                 '   outrow = 0
                'End If
' and need to use outcol +1, outcol + 2  instead og 8,9 etc for the output cells
 
            Next x3
        Next x2
    Next x1
End Sub
Sub
 
Upvote 0
I'm looking for a formula that will take numbers that I have here in a setup like this & make combinations out of all this numbers here, I've noticed the macro written by Myrna Larson on here & just wondering if the macro will work for my setup & if it does how do I go about writing in the macro in Excel I use Open Office. I'm new to Excel & need help.


|B1|B2|B3|B4|B5|MB|
---------------------
|02|04|23|45|58|03|
|04|17|32|55|62|07|
|05|39|48|68|65|09|
|07|45|53|71|70|11|
|10| |57| |74|13|
|15| | | | |15|
 
Upvote 0
Sorry about my setup on the first post I'm trying to correct it, in case that my second attempt doesn't work out. Here is how it is supposed to look, the 13 & 15 on the bottom right is supposed to be under the MB & the 74 left of the 13 is supposed to be under B5 & the 57 is supposed to be under B3.

|B1|B2|B3|B4|B5|MB|
---------------------
|02|04|23|45|58|03|
|04|17|32|55|62|07|
|05|39|48|68|65|09|
|07|45|53|71|70|11|
|10| |57|74| |13|
|15| | | | |15|
 
Upvote 0
Sorry about my setup on the first post I'm trying to correct it, in case that my second attempt doesn't work out. Here is how it is supposed to look, the 13 & 15 on the bottom right is supposed to be under the MB & the 74 left of the 13 is supposed to be under B5 & the 57 is supposed to be under B3.

|B1|B2|B3|B4|B5|MB|
---------------------
|02|04|23|45|58|03|
|04|17|32|55|62|07|
|05|39|48|68|65|09|
|07|45|53|71|70|11|
|10|00|57|00|74|13|
|15|00|00|00|00|15|

I had to use the '00' occupy the empty spaces to correct this.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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