27/15 Total combinations?

Snowy

Member
Giles could you possibly do me a quick macro for excel that will generate all the 15 number combinations for a 27 number lotto.

Cheers!

Tim.:dog:
 

GillesD

Member
15-number combinations

The macro listed below will cycle through each 15-number combinations in a 27 numbers lottery.

The problem is what you want to do with each combination. You can insert some code where indicated to do calculations, manipulations or else. But if you want to list these combninations, you may have a space problem. An Excel sheet with 256 columns and 65,536 rows has 16,277,216 cells. Even by placing one combination per cell, there are not enough cells in a single sheet to contain the 17,383,860 possible 15-number combinations for a 27 numbers lottery.

Option Explicit
Sub Comb_15x27()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer, G As Integer, H As Integer
Dim I As Integer, J As Integer, K As Integer, L As Integer, M As Integer, N As Integer, O As Integer
For A = 1 To 13
For B = A + 1 To 14
For C = B + 1 To 15
For D = C + 1 To 16
For E = D + 1 To 17
For F = E + 1 To 18
For G = F + 1 To 19
For H = G + 1 To 20
For I = H + 1 To 21
For J = I + 1 To 22
For K = J + 1 To 23
For L = K + 1 To 24
For M = L + 1 To 25
For N = M + 1 To 26
For O = N + 1 To 27
' insert code to do what you want with each combination
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
End Sub
 

Sidebar

Top