All possible combinations

uneiman

New Member
Joined
Jul 27, 2002
Messages
44
Is there a way for Excel to LIST all possible combinations of a given range of letters or numbers?
Example:

Team A plays Team B
Team C plays Team D
Team E plays Team F

A&B can not be in the same combination, just like C&D and E&F can not be, because only one of the teams going head to head can win.

I know that there are 8 possible combinations:
ACE, ADE, ADF, ACF, BDF, BDE, BCE, BCF

So can Excel produce this list if I reference the team names in any given cells?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I am reasonably sure I'd posted code on this subject or read someone else's code that worked well and decided not to create my own. You may want to search this forum or the XL newsgroups. Those are the only two cyber-places where I "hang out."

Myrna's excellent code -- that others have pointed you to -- won't work, at least I don't think it will. You want to select one item from each of several buckets. Myrna picks all items from a different bucket.

Is there a way for Excel to LIST all possible combinations of a given range of letters or numbers?
Example:

Team A plays Team B
Team C plays Team D
Team E plays Team F

A&B can not be in the same combination, just like C&D and E&F can not be, because only one of the teams going head to head can win.

I know that there are 8 possible combinations:
ACE, ADE, ADF, ACF, BDF, BDE, BCE, BCF

So can Excel produce this list if I reference the team names in any given cells?
 
Upvote 0
It's like worldcup team chart !! :biggrin:


Copy this code

Code:
Sub SampleCode() 

Dim intA As Integer 
Dim intB As Integer 
Dim intC As Integer 
Dim intD As Integer 

Dim varArray_A As Variant 
Dim varArray_B As Variant 
Dim varArray_C As Variant 

Dim varTemp As Variant 
Dim shtSheet As Worksheet 

Set shtSheet = ActiveSheet 

varArray_A = Array("A", "B") 
varArray_B = Array("C", "D") 
varArray_C = Array("E", "F") 

For intA = 0 To 1 
    For intB = 0 To 1 
           For intC = 0 To 1 
                varTemp = varArray_A(intA) & varArray_B(intB) & varArray_C(intC) 
                    With shtSheet.Range("a1") 
                          .Offset(intD, 0) = varTemp 
                        intD = intD + 1 
                     End With 
            Next 
     Next 
Next 
End Sub


or


Code:
Sub SampleCode() 

Dim intA As Integer 
Dim intB As Integer 
Dim intC As Integer 
Dim intD As Integer 
Dim intE As Integer 

Dim varArray_A As Variant 
Dim varArray_B As Variant 
Dim varArray_C As Variant 
Dim varArray_D As Variant 

Dim varTemp As Variant 
Dim shtSheet As Worksheet 

Set shtSheet = ActiveSheet 

varArray_A = Array("A", "B") 
varArray_B = Array("C", "D") 
varArray_C = Array("E", "F") 
varArray_D = Array("G", "H")


For intA = 0 To 1 
    For intB = 0 To 1 
           For intC = 0 To 1 
                  For intE = 0 To 1 
                    varTemp = varArray_A(intA) & varArray_B(intB) & varArray_C(intC) & varArray_D(intE) 
                       With shtSheet.Range("a1") 
                          .Offset(intD, 0) = varTemp 
                        intD = intD + 1 
                       End With 
                  Next
            Next 
     Next 
Next 
End Sub
 
Upvote 0
"scu77 ... is there a link to that tool you posted which is in English?"


hey :biggrin: jmckeone!

Do you have any problem?
 
Upvote 0
Found answer. Link you posted for Combo.xla only works in Internet Explorer. I have it now. Thank you.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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