- Home
- Premium Memberships
- Lottery Results
- Forums
- Predictions
- Lottery Post Videos
- News
- Search Drawings
- Search Lottery Post
- Lottery Systems
- Lottery Charts
- Lottery Wheels
- Worldwide Jackpots
- Quick Picks
- On This Day in History
- Blogs
- Online Games
- Premium Features
- Contact Us
- Whitelist Lottery Post
- Rules
- Lottery Book Store
- Lottery Post Gift Shop
The time is now 12:42 pm
You last visited
May 21, 2024, 12:42 pm
All times shown are
Eastern Time (GMT-5:00)
Excel VBA - Generate Pairs & Trips to a Text File
Published:
Updated:
1. Create a new folder on your C: Drive and name it Lotto543 (c:\Lotto543)
2. Open Excel and right-click any Tab at the bottom and select "ViewCode"
3. When the Window opens go to the top Main Menu and select > Insert > Module
4. Copy and paste the following code into the right workspace where you see the blinking cursor.
Sub Generate43C2()
Open "c:\Lotto543\L543.txt" For Output As #1
For i1 = 1 To 43 - 1
For i2 = i1 + 1 To 43 - 0
LexiNum = LexiNum + 1
Print #1, Format(LexiNum, "000") & " " & Format(i1, "0") & "," & Format(i2, "0")
Next
Next
Close #1
End Sub
=======================================================================
This generates all 903 Pairs for the 5/43 Lottery Game to a text file named L43.txt located at C:\Lotto543
If your drive designation is different from "C:\" then you will need to change the following code to reflect the code:
For example if your drive designation is the letter D:\ you would change th following line of code to the following:
Open "d:\Lotto543\L543.txt" For Output As #1
============================================================================
If your Lottery Game is a 5/39 game you can change or create a new folder and name the folder c:\Lotto539
and change the following code:
Sub Generate39C2()
Open "c:\Lotto539\L539.txt" For Output As #1
For i1 = 1 To 39 - 1
For i2 = i1 + 1 To 39 - 0
LexiNum = LexiNum + 1
Print #1, Format(LexiNum, "000") & " " & Format(i1, "0") & "," & Format(i2, "0")
Next
Next
Close #1
End Sub
=======================================================================
The "LexiNum" is actually the Lexicographic Pairs designation number.
The Excel formula for calculating the number of pairs in your lottery game is =COMBIN(43,2) where "X" is the total number of balls (43) and "N" is the number of digits = 903 for a 5/43 game
or =COMBIN(39/2) = 741 Pairs for a 5/39 lottery game.
=======================================================================
For creating 3 Number Combinations (9,139) for a 5/39 Game =COMBIN(39,3). This code below will generate all 9,139 trips to your folder C:\Lotto539. If you open the folder you should see a text file L539Trips.txt inside the folder. Remember to create your new folder c:\Lotto539 first before running the code.
Sub Generate39C3()
Open "c:\Lotto539\L539Trips.txt" For Output As #1
For i1 = 1 To 39 - 2
For i2 = i1 + 1 To 39 - 1
For i3 = i2 + 1 To 39 - 0
LexiNum = LexiNum + 1
Print #1, Format(LexiNum, "000") & " " & Format(i1, "0") & "," & Format(i2, "0") & "," & Format(i3, "0")
Next
Next
Next
Close #1
End Sub
======================================================================================
Good Luck!!
Comments
can you please confirm. I would like to use this with Pick3 or 6/49
for 6/49 I tried
code:
Sub Generate49C2()
Open "c:\Lotto649\L649.txt" For Output As #1
For i1 = 1 To 49 - 1
For i2 = i1 + 1 To 49 - 0
LexiNum = LexiNum + 1
Print #1, Format(LexiNum, "000") & " " & Format(i1, "0") & "," & Format(i2, "0")
Next
Next
Close #1
End Sub
Post a Comment
Please Log In
To use this feature you must be logged into your Lottery Post account.
Not a member yet?
If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.
Register