You need some tricks to write the algorithm for drawing randomly without repeating. The following is my codes to write random draw no. 1 to 10 into cells(1, 1) to cells(1, 10) sequentially. You can replace the total no. to any number you want.
Sub Draw_Randomly()
Dim Total As Integer, Occupy() As Boolean, Position() As Integer
Dim Remain As Integer
Total = 10
ReDim Occupy(1 To Total)
ReDim Position(1 To Total)
Remain = Total
For i = 1 To Total
Position(i) = i
Occupy(i) = False
Next i
Randomize
For i = 1 To Total
n = Int(Rnd * Remain) + 1
Cells(i, 1) = Position(n)
Remain = Remain - 1
For j = n To Remain
Position(j) = Position(j + 1)
Next j
Next i
End Sub
Bookmarks