Gruppe
Allgemein
Problem
Wie kann ich Lottozahlen nach dem Zufallsprinzip ermitteln?
StandardModule: basMain
Sub Lotto()
Dim wks As Worksheet
Dim rng As Range
Dim iLotto As Integer, iCount As Integer
Randomize
Set wks = Worksheets("Nummern")
For iLotto = 1 To 49
wks.Cells(iLotto, 1).Value = iLotto
Next iLotto
For Each rng In Range("A1:G7").Cells
iCount = WorksheetFunction.CountA(wks.Columns(1))
iLotto = Int((iCount * Rnd) + 1)
rng.Value = wks.Cells(iLotto, 1).Value
wks.Rows(iLotto).Delete
Next rng
End Sub