Listing of all sequences
I tried to figure it out based on all combinations for a 6/49 lottery but then a light come on and it was so simple. The macro was developed to veriy the answer.
The following macro is not very elegant but it does the job.
Sub LD_Combo()
Dim A As Long, B As Long, C As Long, D As Long, E As Long, F As Long
Application.ScreenUpdating = False
' Set-up
Range("A1").Select
ActiveCell.Offset(0, 0).Value = " 6# comb."
ActiveCell.Offset(0, 1).Value = " 5# comb."
ActiveCell.Offset(0, 2).Value = " 4# comb."
ActiveCell.Offset(0, 3).Value = " 3# comb."
ActiveCell.Offset(0, 4).Value = " 2# comb."
Columns("A:A").Select
Selection.NumberFormat = "000000"
Columns("B:B").Select
Selection.NumberFormat = "00000"
Columns("C:C").Select
Selection.NumberFormat = "0000"
Columns("D
").Select
Selection.NumberFormat = "000"
Columns("E:E").Select
Selection.NumberFormat = "00"
' 6-number combo
Range("A2").Select
For A = 0 To 4
For B = A + 1 To 5
For C = B + 1 To 6
For D = C + 1 To 7
For E = D + 1 To 8
For F = E + 1 To 9
ActiveCell.Value = 100000 * A + 10000 * B + 1000 * C + 100 * D + 10 * E + F
ActiveCell.Offset(1, 0).Select
Next F
Next E
Next D
Next C
Next B
Next A
' 5-number combo
Range("B2").Select
For A = 0 To 5
For B = A + 1 To 6
For C = B + 1 To 7
For D = C + 1 To 8
For E = D + 1 To 9
ActiveCell.Value = 10000 * A + 1000 * B + 100 * C + 10 * D + E
ActiveCell.Offset(1, 0).Select
Next E
Next D
Next C
Next B
Next A
' 4-number combo
Range("C2").Select
For A = 0 To 6
For B = A + 1 To 7
For C = B + 1 To 8
For D = C + 1 To 9
ActiveCell.Value = 1000 * A + 100 * B + 10 * C + D
ActiveCell.Offset(1, 0).Select
Next D
Next C
Next B
Next A
' 3-number combo
Range("D2").Select
For A = 0 To 7
For B = A + 1 To 8
For C = B + 1 To 9
ActiveCell.Value = 100 * A + 10 * B + C
ActiveCell.Offset(1, 0).Select
Next C
Next B
Next A
' 2-number combo
Range("E2").Select
For A = 0 To 8
For B = A + 1 To 9
ActiveCell.Value = 10 * A + B
ActiveCell.Offset(1, 0).Select
Next B
Next A
Application.ScreenUpdating = True
Range("A1").Select
End Sub
Take note that the line "Columns("D
").Select"
should actually read "Columns("D : D").Select" but with no spaces on each side of the :
Smileys can be fun but here it is a problem.