Hi everybody
I turn to you because I have a question.
The following document lists the extracted numbers and a generated list.
I ran into drawing lots of numbers that had already been played.
How could the number strings that have already been drawn be filtered out in the generator?
So some cleverness should be added to the code below!
Thanks for the help.
I don't know how to put a picture.
(C3: I103) - historical data
(L3: R13) -generated data
Sub allgen()
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim sor_szam As Integer
Dim gorgo As Variant
Munka1.Range("L3:R100").ClearContents
timebegin = Now()
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.StatusBar = "Executing..."
Randomize Timer
For i = 3 To 103
For J = 1 To 7
If J = 1 Then 'elso szám generálása
ag = Int((35 - 1 + 1) * Rnd + 1)
Cells(i, 12) = ag
End If
If J = 2 Then 'második szám generálása
bg = Int((35 - 1 + 1) * Rnd + 1)
Do While bg = ag
bg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 13) = bg
End If
If J = 3 Then 'harmadik szám generálása
cg = Int((35 - 1 + 1) * Rnd + 1)
Do While cg = ag Or cg = bg
cg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 14) = cg
End If
If J = 4 Then 'negyedik szám generálása
dg = Int((35 - 1 + 1) * Rnd + 1)
Do While dg = ag Or dg = bg Or dg = cg
dg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 15) = dg
End If
If J = 5 Then 'ötödik szám generálása
eg = Int((35 - 1 + 1) * Rnd + 1)
Do While eg = ag Or eg = bg Or eg = cg Or eg = dg
eg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 16) = eg
End If
If J = 6 Then 'hatodik szám generálása
fg = Int((35 - 1 + 1) * Rnd + 1)
Do While fg = ag Or fg = bg Or fg = cg Or fg = dg Or fg = eg
fg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 17) = fg
End If
If J = 7 Then 'hetedik szám generálása
gg = Int((35 - 1 + 1) * Rnd + 1)
Do While gg = ag Or gg = bg Or gg = cg Or gg = dg Or gg = eg Or gg = fg
gg = Int((35 - 1 + 1) * Rnd + 1)
Loop
Cells(i, 18) = gg
End If
Next J
Next i
With ActiveSheet
FirstRow = 3 'change to 2 if there are headings
LastRow = .Cells(.Rows.Count, "L").End(xlUp).Row
For iRow = FirstRow To LastRow
With .Cells(iRow, "L").Resize(1, 7)
.Sort Key1:=.Columns(1), Order1:=xlAscending, Header:=x1No, OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
End With
Next iRow
End With
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
Set gorgo = ActiveSheet.UsedRange
End Sub