View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Combination of given numbers

You could try a macro. Assuming the 12 items are on Sheet1 in cells A1:A12
and you want the list on Sheet2, starting in cell A2 - this appears to give
the results you want:

Sub ListCombinations()
Dim rngList As Range
Dim wksDest As Worksheet
Dim a As Long, b As Long, c As Long
Dim d As Long, e As Long, f As Long
Dim lngElements As Long

Set rngList = Sheet1.Range("A1:A12")
Set wksDest = Sheet2
lngElements = rngList.Cells.Count

For a = 1 To lngElements - 5
For b = a + 1 To lngElements - 4
For c = b + 1 To lngElements - 3
For d = c + 1 To lngElements - 2
For e = d + 1 To lngElements - 1
For f = e + 1 To lngElements
wksDest.Cells(Rows.Count, 1).End(xlUp)(2, 1).Value = _
rngList(a) & ", " & rngList(b) & ", " & rngList(c) & ", " & _
rngList(d) & ", " & rngList(e) & ", " & rngList(f)
Next f
Next e
Next d
Next c
Next b
Next a
End Sub


"Rendar" wrote:

Hello,
I have a list of twelve distinct numbers and would like to somehow display
all distinct combinations of 6 on Excel. The COMBIN function just gives me
the total number of them (924). Is there a way to explicitly show them?