listing all possible combinations from a list of names

BrennanB

New Member
Joined
May 23, 2015
Messages
2
We are not proficient at Macros and wanted to see if there is a formula for one row or column of 12 names that we can extract every combination of 3 unique names
I know this may be a simple task for many but we cannot figure out how to extract all possible combinations of 3 names given 12 names
thank you for any insight you can provide
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi,

Put your names in column A and try this code, there are 220 combinations of 3 from 12 and this will put them in column B

EDIT...I should have added, there may be a formula but I can't imagine what form it might take.


Code:
Sub combinations()
Dim Last As Long, i As Long, j As Long
Dim k As Long, L As Long
Last = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To Last - 2
        For j = i + 1 To Last - 1
            For k = j + 1 To Last
                Cells(L + 1, 2) = Cells(i, 1) & ", " & Cells(j, 1) & ", " & Cells(k, 1)
                L = L + 1
            Next
        Next
    Next
 End Sub
 
Last edited:
Upvote 0
Hi,

Put your names in column A and try this code, there are 220 combinations of 3 from 12 and this will put them in column B

EDIT...I should have added, there may be a formula but I can't imagine what form it might take.


Code:
Sub combinations()
Dim Last As Long, i As Long, j As Long
Dim k As Long, L As Long
Last = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To Last - 2
        For j = i + 1 To Last - 1
            For k = j + 1 To Last
                Cells(L + 1, 2) = Cells(i, 1) & ", " & Cells(j, 1) & ", " & Cells(k, 1)
                L = L + 1
            Next
        Next
    Next
 End Sub



This worked perfectly ! Thank you !!!!!
 
Upvote 0

Forum statistics

Threads
1,207,173
Messages
6,076,923
Members
446,242
Latest member
JECYN

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