Using Excel 2010
Hello,
I want to know how many combinations could be made if value 1 and 2 split in 14 columns which row sum come up = 10
Please see the attached workbook with few examples in it.
Regards,
Moti
Using Excel 2010
Hello,
I want to know how many combinations could be made if value 1 and 2 split in 14 columns which row sum come up = 10
Please see the attached workbook with few examples in it.
Regards,
Moti
try this code
PHP Code:
Option Explicit
Sub combi()
Dim n1&, n2&, n3&, n4&, n5&, n6&, n7&, n8&, n9&, n10&, n11&, n12&, n13&, n14&
Dim k&, res(1 To 1000000, 1 To 14)
Const TOTA = 10 ' Change it
For n1 = 0 To 2: For n2 = 0 To 2: For n3 = 0 To 2: For n4 = 0 To 2: For n5 = 0 To 2: For n6 = 0 To 2: For n7 = 0 To 2
For n8 = 0 To 2: For n9 = 0 To 2: For n10 = 0 To 2: For n11 = 0 To 2: For n12 = 0 To 2: For n13 = 0 To 2: For n14 = 0 To 2
If n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 = TOTA Then
k = k + 1
res(k, 1) = n1: res(k, 2) = n2: res(k, 3) = n3: res(k, 4) = n4: res(k, 5) = n5: res(k, 6) = n6: res(k, 7) = n7
res(k, 8) = n8: res(k, 9) = n9: res(k, 10) = n10: res(k, 11) = n11: res(k, 12) = n12: res(k, 13) = n13: res(k, 14) = n14
End If
Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next: Next:
Range("C6:P100000").ClearContents
Range("C6").Resize(k, 14).Value = res
End Sub
Quang PT
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks