Excel - Creating Pick 3 and Pick 4 Combinations VBA

Published:

Below is a link for creating 1,000 Pick 3 combinations and 10,000 Pick 4 combinations:

http://www.box.net/shared/t9ktq6klm5

Thanks to GillesD at lotto649 forum.

=====================================================

Pick 4 Code:

Option Explicit
Dim A As Integer, B As Integer, C As Integer, D As Integer
Dim X As Double

Sub CombininationsPick4()

Columns("A:E").Select
    Selection.ClearContents
    Range("G1").Select
   
' Generates all combinations for a pick-4 lottery

Range("A1").Select

X = 1

For A = 0 To 9
For B = 0 To 9
For C = 0 To 9
For D = 0 To 9

ActiveCell.Offset(X, 0).Value = X
ActiveCell.Offset(X, 1).Value = A
ActiveCell.Offset(X, 2).Value = B
ActiveCell.Offset(X, 3).Value = C
ActiveCell.Offset(X, 4).Value = D

X = X + 1

Next D
Next C
Next B
Next A

End Sub

===============================================

Pick 3 Code:

Option Explicit
Dim A As Integer, B As Integer, C As Integer

Dim X As Double

Sub CombininationsPick3()

Columns("A:D").Select
    Selection.ClearContents
    Range("G1").Select
   
' Generates all combinations for a pick-3 lottery

Range("A1").Select

X = 1

For A = 0 To 9
For B = 0 To 9
For C = 0 To 9


ActiveCell.Offset(X, 0).Value = X
ActiveCell.Offset(X, 1).Value = A
ActiveCell.Offset(X, 2).Value = B
ActiveCell.Offset(X, 3).Value = C


X = X + 1


Next C
Next B
Next A

End Sub

===========================================================

Entry #151

Comments

This Blog entry currently has no comments.

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