Lottery combinations

K

K

Hi all, I am trying to get all combinations of euro million lotto
lottery by macro code. In this lottery you need to chose 5 numbers
from 1 to 50 and then you have to chose 2 bonus numbers from 1 to 10
and like this you get 7 numbers all together. I got two macros below
in which "MACRO 1" gives me all the possible 5 combinations from
numbers 1 to 50 which is 2118760 combinations in total and "MACRO 2"
gives all possible 2 combinations from numbers 1 to 10 which are 45
combintions in total.

Macro 1 Results are something like this:-

01-02-03-04-05
01-02-03-04-06
01-02-03-04-07 …………..etc

Macro 2 Results are something like this:-

01-02
01-03
01-04…………etc

Whith macros below I am half way there but I am not getting what I
want as I need both macros result combine in shape of 7 combinations
but I don’t know how can I do that. Is there any friend can give me
help on this that how can I combine both macro result so i get 7
combination something like this (see below) or i can achive what i
want with more better and small macro. any help or idea will be much
appricated

01-02-03-04-05-01-02
01-02-03-04-05-01-03
01-02-03-04-05-01-04…………etc




MACRO
1 :=*****************************************************************>

Sub List_ALL_550_Combinations()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As
Integer
Dim n As Long

Range("A4").Select
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

n = 0

For A = 1 To 46
For B = A + 1 To 47
For C = B + 1 To 48
For D = C + 1 To 49
For E = D + 1 To 50
n = n + 1
If n = 1048576 Then
n = 1
ActiveCell.Offset(-1048575, 1).Select
End If
ActiveCell.Value = _
Application.WorksheetFunction.Text(A, "00") & "-" _
& Application.WorksheetFunction.Text(B, "00") & "-" _
& Application.WorksheetFunction.Text(C, "00") & "-" _
& Application.WorksheetFunction.Text(D, "00") & "-" _
& Application.WorksheetFunction.Text(E, "00")
ActiveCell.Offset(1, 0).Select

Next E
Next D
Next C
Next B
Next A

With ActiveSheet
Cells.Select
Selection.ColumnWidth = 18
End With

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

<*******************************************************************************

MACRO
2:=*******************************************************************>

Sub List_ALL_210_Combinations()
Dim A As Integer, B As Integer
Dim n As Long

Range("A4").Select
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

n = 0

For A = 1 To 9
For B = A + 1 To 10
n = n + 1

ActiveCell.Value = _
Application.WorksheetFunction.Text(A, "00") & "-" _
& Application.WorksheetFunction.Text(B, "00")
ActiveCell.Offset(1, 0).Select


Next B
Next A

With ActiveSheet
Cells.Select
Selection.ColumnWidth = 18
End With

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

<*******************************************************************************
 
J

Joel

Sub List_ALL_550_Combinations()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As
Integer
Dim n As Long

Range("A4").Select
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

n = 0

For A = 1 To 46
For B = A + 1 To 47
For C = B + 1 To 48
For D = C + 1 To 49
For E = D + 1 To 50
For F = 1 To 9
For G = F + 1 To 10

n = n + 1
If n = 1048576 Then
n = 1
ActiveCell.Offset(-1048575, 1).Select
End If
ActiveCell.Value = format(A, "00") & "-" _
& format(B, "00") & "-" _
& format(C, "00") & "-" _
& format(D, "00") & "-" _
& format(E, "00") & "-" _
& format(F, "00") & "-" _
& format(G, "00")
ActiveCell.Offset(1, 0).Select
Next G
Next F
Next E
Next D
Next C
Next B
Next A

With ActiveSheet
Cells.Select
Selection.ColumnWidth = 18
End With

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
 
K

K

Sub List_ALL_550_Combinations()
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As
Integer
Dim n As Long

Range("A4").Select
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

n = 0

For A = 1 To 46
  For B = A + 1 To 47
    For C = B + 1 To 48
      For D = C + 1 To 49
        For E = D + 1 To 50
           For F = 1 To 9
              For G = F + 1 To 10

          n = n + 1
            If n = 1048576 Then
              n = 1
              ActiveCell.Offset(-1048575, 1).Select
            End If
            ActiveCell.Value = format(A, "00") & "-" _
            & format(B, "00") & "-" _
            & format(C, "00") & "-" _
            & format(D, "00") & "-" _
            & format(E, "00") & "-" _
            & format(F, "00") & "-" _
            & format(G, "00")
            ActiveCell.Offset(1, 0).Select
              Next G
           Next F
        Next E
      Next D
    Next C
  Next B
Next A

With ActiveSheet
  Cells.Select
  Selection.ColumnWidth = 18
End With

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub























- Show quoted text -

Thanks Joel you are a real hero of macro. I cant believe that it was
just little adjustment and i have spent ages to solve this. Thanks
again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top