Sub GetUniqueRandomNumbers()
Dim iAdd As Integer
Dim iLimit As Integer
Dim iCheck As Integer
Dim iRnd As Integer
Dim UniqueNumbers As New Collection
Workbooks.Add
iLimit = 52
For iAdd = 1 To iLimit
StartAgain:
iRnd = Int((iLimit - 1 + 1) * Rnd + 1)
On Error Resume Next
UniqueNumbers.Add iRnd, CStr(iRnd)
On Error GoTo 0
Next iAdd
If UniqueNumbers.Count < iLimit Then GoTo StartAgain
For iCheck = 1 To iLimit
ActiveSheet.Cells(iCheck, 1).Value = UniqueNumbers.Item(iCheck)
Next iCheck
End Sub
maandag 23 maart 2009
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten