Gruppe
Allgemein
Problem
Auf Schaltflächenclick sollen im Bereich B2:IV7 Lottozahlen generiert werden, die im Bereich B14:D25 gem. dem Ergebnis in Spalte auszuwerten sind.
StandardModule: Modul1
Sub SetNumbers()
Dim rng As Range, rngAll As Range
Dim iCol As Integer, iRow As Integer, iRandomize As Integer
Range("B2:IV7").ClearContents
For iCol = 2 To 256
Set rngAll = Range(Cells(2, iCol), Cells(7, iCol))
Randomize
For Each rng In rngAll
iRandomize = Int((49 * Rnd) + 1)
Do Until WorksheetFunction.CountIf(rngAll, iRandomize) = 0
iRandomize = Int((49 * Rnd) + 1)
Loop
rng.Value = iRandomize
Next rng
Next iCol
End Sub