GillesD Kindly Produced this Macro a while ago to List ALL Combinations for a 649 Lotto :-
Option Explicit
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer
Dim N As Long
Sub Combinations()
Range("A1").Select
Application.ScreenUpdating = False
N = 0
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
N = N + 1
ActiveCell.Value = A & "-" & B & "-" & C & "-" & D & "-" & E & "-" & F
ActiveCell.Offset(1, 0).Select
Next F
Next E
Next D
Next C
Next B
Next A
Application.ScreenUpdating = True
End Sub
I would like to be Able to Put a Range ( Using an "IF" Statement ) of Lexicographic Index Numbers, so that if a Combination is Within that Range it will be Accepted, and if a Combination is Outside that Range it will be Ignored.
So Basically, as it Runs through the Macro it Checks if the Lexicographic Number of that Combination is Within the Range Set.
Something Like ( as a Sequential Call ) :-
If LexNumber > 22500 And LexNumber < 50000 Then
Function :-
Function LexNumber()
LexNumber = False
*Code Will Go Here* Then
LexNumber = True
End Function
If we were to Use an Excel Formula for Example to do this ( For a Combination of 6 Numbers in Cells O14:T14 ) it would be :-
=COMBIN(49,6)-IF(44-O14>0,COMBIN(49-O14,6),0)-IF(45-P14>0,COMBIN(49-P14,5),0)-IF(46-Q14>0,COMBIN(49-Q14,4),0)-IF(47-R14>0,COMBIN(49-R14,3),0)-IF(48-S14>0,COMBIN(49-S14,2),0)-IF(49-T14>0,COMBIN(49-T14,1),0)
Any Help would be Appreciated.
All the Best
PAB

Option Explicit
Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer
Dim N As Long
Sub Combinations()
Range("A1").Select
Application.ScreenUpdating = False
N = 0
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
N = N + 1
ActiveCell.Value = A & "-" & B & "-" & C & "-" & D & "-" & E & "-" & F
ActiveCell.Offset(1, 0).Select
Next F
Next E
Next D
Next C
Next B
Next A
Application.ScreenUpdating = True
End Sub
I would like to be Able to Put a Range ( Using an "IF" Statement ) of Lexicographic Index Numbers, so that if a Combination is Within that Range it will be Accepted, and if a Combination is Outside that Range it will be Ignored.
So Basically, as it Runs through the Macro it Checks if the Lexicographic Number of that Combination is Within the Range Set.
Something Like ( as a Sequential Call ) :-
If LexNumber > 22500 And LexNumber < 50000 Then
Function :-
Function LexNumber()
LexNumber = False
*Code Will Go Here* Then
LexNumber = True
End Function
If we were to Use an Excel Formula for Example to do this ( For a Combination of 6 Numbers in Cells O14:T14 ) it would be :-
=COMBIN(49,6)-IF(44-O14>0,COMBIN(49-O14,6),0)-IF(45-P14>0,COMBIN(49-P14,5),0)-IF(46-Q14>0,COMBIN(49-Q14,4),0)-IF(47-R14>0,COMBIN(49-R14,3),0)-IF(48-S14>0,COMBIN(49-S14,2),0)-IF(49-T14>0,COMBIN(49-T14,1),0)
Any Help would be Appreciated.
All the Best
PAB
