Hello,
I come across vba coded by Ruddles under the link below:
http://www.mrexcel.com/forum/excel-questions/539512-lottery-combinations-2.html#post2666862
And modified to work with 5/50 lottery it works perfect generate 2.118.760 all combinations in to 33 sheets.
As shown below
I am looking please if some one can modify an existing code or make a new VBA for lottery 5/50 which has total 2.118.760 combinations I do not need VBA that generate all combinations only with the required odd even pattern I have no idea who much will be get with each pattern?
For Example:
ODD-EVEN
0-5
1-4
2-3
3-2
4-1
5-0
I mean VBA give input option For Odd & Even and generate all possible combination for that selected pattern
For example if input is 2-odd & 3-even numbers VBA generate following set of combination as shown
Thanks In Advance
Using Excel 2000
Regards,
Moti
I come across vba coded by Ruddles under the link below:
http://www.mrexcel.com/forum/excel-questions/539512-lottery-combinations-2.html#post2666862
And modified to work with 5/50 lottery it works perfect generate 2.118.760 all combinations in to 33 sheets.
As shown below
Code:
Option Explicit
Public Sub Generate6ex49()
Const MainSheet As String = "Sheet1"
Const SheetPrefix As String = "Part"
Const SplitPoint As Long = 65000
Const HighBall As Integer = 50
Dim iPtr As Integer
Dim sFileName As String
Dim SheetNumber As Integer
Dim iRow As Long
Dim iRec As Long
Dim iLastRow As Long
Dim ws As Worksheet
Dim sMessage As String
Dim sTime As Date
Dim p1 As Integer
Dim p2 As Integer
Dim p3 As Integer
Dim p4 As Integer
Dim p5 As Integer
Dim p6 As Integer
For Each ws In ThisWorkbook.Worksheets
If Left(ws.Name, Len(SheetPrefix)) = SheetPrefix Then
Application.DisplayAlerts = False
On Error Resume Next
ws.Delete
On Error GoTo 0
Application.DisplayAlerts = True
End If
Next ws
Sheets(MainSheet).Columns("A:B").ClearContents
sMessage = vbCrLf & "Workbook reset. Proceed to create combination records?" _
& Space(10) & vbCrLf & vbCrLf _
& "Warning: this will take several minutes!"
If MsgBox(sMessage, vbYesNo + vbQuestion) = vbNo Then
Exit Sub
End If
Sheets(MainSheet).Range("A1:B1").Font.Bold = True
Sheets(MainSheet).Range("A1") = "Worksheet"
Sheets(MainSheet).Range("B1") = "Records"
sTime = Now()
SheetNumber = 0
iRow = SplitPoint
iRec = 0
For p1 = 1 To HighBall - 4
For p2 = p1 + 1 To HighBall - 3
For p3 = p2 + 1 To HighBall - 2
For p4 = p3 + 1 To HighBall - 1
'For p5 = p4 + 1 To HighBall - 1
For p5 = p4 + 1 To HighBall
iRec = iRec + 1
iRow = iRow + 1
If iRow > SplitPoint Then
If SheetNumber > 0 Then
iLastRow = Sheets(MainSheet).Cells(Rows.Count, 1).End(xlUp).Row
Sheets(MainSheet).Cells(iLastRow, 2) = iRow - 1
End If
SheetNumber = SheetNumber + 1
Sheets.Add(After:=Sheets(Sheets.Count)).Name = SheetPrefix & Right("00" & CStr(SheetNumber), 3)
Sheets(MainSheet).Activate
iLastRow = Sheets(MainSheet).Cells(Rows.Count, 1).End(xlUp).Row
Set ws = Sheets(SheetPrefix & Right("00" & CStr(SheetNumber), 3))
Sheets(MainSheet).Cells(iLastRow + 1, 1) = ws.Name
iRow = 1
End If
ws.Cells(iRow, 1) = p1
ws.Cells(iRow, 2) = p2
ws.Cells(iRow, 3) = p3
ws.Cells(iRow, 4) = p4
ws.Cells(iRow, 5) = p5
'ws.Cells(iRow, 6) = p6
DoEvents
'Next p6
Next p5
Next p4
Next p3
Next p2
Next p1
Sheets(MainSheet).Cells(iLastRow + 1, 2) = iRow
Sheets(MainSheet).Cells(iLastRow + 2, 1) = "Total"
Sheets(MainSheet).Cells(iLastRow + 2, 2) = iRec
Sheets(MainSheet).Columns("A:B").EntireColumn.AutoFit
Sheets(MainSheet).Range("A1").Select
MsgBox vbCrLf & Format(iRec, "#,###") & " records created" & Space(10) & vbCrLf & vbCrLf _
& CStr(SheetNumber) & " worksheets created" & vbCrLf & vbCrLf _
& "Run time: " & Format(Now() - sTime, "hh:nn:ss"), vbOKOnly + vbInformation
End Sub
I am looking please if some one can modify an existing code or make a new VBA for lottery 5/50 which has total 2.118.760 combinations I do not need VBA that generate all combinations only with the required odd even pattern I have no idea who much will be get with each pattern?
For Example:
ODD-EVEN
0-5
1-4
2-3
3-2
4-1
5-0
I mean VBA give input option For Odd & Even and generate all possible combination for that selected pattern
For example if input is 2-odd & 3-even numbers VBA generate following set of combination as shown
Book1 | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | n1 | n2 | n3 | n4 | n5 | ||
2 | 16 | 29 | 32 | 36 | 41 | ||
3 | 2 | 26 | 27 | 40 | 49 | ||
Odd Even |
Thanks In Advance
Using Excel 2000
Regards,
Moti
Last edited: