Welcome Guest
The time is now 11:19 pm
You last visited December 12, 2017, 10:15 pm
All times shown are
Eastern Time (GMT-5:00)

# 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