Hey, I am trying to find the different combinations that can be formed by choosing 11 out of 22 objects ( i.e. C(22,11) ). I have posted below the code I tried using. the problem is that this code give me all possible combinations whereas I only need different ways in which 11 objects can be chosen out of 22.
VBA Code:
items(1) = "albert"
items(2) = "pane"
items(3) = "drey"
items(4) = "max"
items(5) = "pat"
items(6) = "sam"
items(7) = "shay"
items(8) = "hem"
items(9) = "asa"
items(10) = "stone"
items(11) = "sunderland"
items(12) = "christian"
items(13) = "hare"
items(14) = "rob"
items(15) = "sir"
items(16) = "jamie"
items(17) = "gray"
items(18) = "khan"
items(19) = "missy"
items(20) = "seed"
items(21) = "afb"
items(22) = "cole"
Set x = ThisWorkbook.Sheets.Add
For a = True To False
For b = True To False
For c = True To False
For d = True To False
For e = True To False
For f = True To False
For g = True To False
For h = True To False
For i = True To False
For j = True To False
For k = True To False
For l = True To False
For m = True To False
For n = True To False
For o = True To False
For p = True To False
For q = True To False
For r = True To False
For s = True To False
For t = True To False
For u = True To False
For v = True To False
z = z + 1
txt = "("
If a Then txt = txt & items(1) & ", "
If b Then txt = txt & items(2) & ", "
If c Then txt = txt & items(3) & ", "
If d Then txt = txt & items(4) & ", "
If e Then txt = txt & items(5) & ", "
If f Then txt = txt & items(6) & ", "
If g Then txt = txt & items(7) & ", "
If h Then txt = txt & items(8) & ", "
If i Then txt = txt & items(9) & ", "
If j Then txt = txt & items(10) & ", "
If k Then txt = txt & items(11) & ", "
If l Then txt = txt & items(12) & ", "
If m Then txt = txt & items(13) & ", "
If n Then txt = txt & items(14) & ", "
If o Then txt = txt & items(15) & ", "
If p Then txt = txt & items(16) & ", "
If q Then txt = txt & items(17) & ", "
If r Then txt = txt & items(18) & ", "
If s Then txt = txt & items(19) & ", "
If t Then txt = txt & items(20) & ", "
If u Then txt = txt & items(21) & ", "
If v Then txt = txt & items(22) & ", "
txt = txt & ")"
txt = Replace(txt, ", )", ")")
x.Cells(z, 1).Value = z
x.Cells(z, 2).Value = txt
Next v
Next u
Next t
Next s
Next r
Next q
Next p
Next o
Next n
Next m
Next l
Next k
Next j
Next i
Next h
Next g
Next f
Next e
Next d
Next c
Next b
Next a
MsgBox z & " combinations found.", vbInformation
End Sub