You could throw my code into a for loop. Try the following (I commented out all the lines so you would know what is happening):<pre>Sub PINCreate()
Dim RndNo As Long 'Declaring the random number variable
Dim Test As Long 'Declaring the variable that match will return
Dim i As Long 'Declaring the counter variable for the for loop
For i = 2 To 1501 'Starting the for loop that will loop 1500 times
Randomize 'Initializing the random number generator
Do 'Starts the do loop
RndNo = Int((9999 - 1000 + 1) * Rnd + 1000) 'Calculates a random number between 1000 and 9999
On Error Resume Next 'Bypassing the error that MATCH will create if there are no matches
Test = Application.Match(RndNo, Range(Cells(1, 1), Cells(i, 1)), 0) 'Testing for matches of RndNo in the worksheet
If Err.Number = 13 Then 'If statement for error, if there are no matches, the error will be 13
GoTo FoundUnique 'If there are no matches that means RndNo is unique
Err.Clear 'Clearing the error so it can be used again
End If 'Ending the if statement
Loop 'Makes the do loop restart
FoundUnique: 'This is where the code jumps to when a unique number (RndNo) is found
Cells(i, 1) = RndNo 'Sets the proper cell in the list equal to the RndNo
'FYI Cells(i,1) refers to the cell in row i and column 1
Next i 'Restarts the for loop
End Sub</pre>
Or you could follow the link posted by Tushar. It might be easier for you.
http://groups.google.com/groups?selm=MPG.1689584b91ef5e5298a3d4@msnews.microsoft.com
_________________
Kind regards,<font size="5"><sup><span style="text-decoration: overline">AL</span></sup><u><sub>CHARA</sub></u></font
This message was edited by Al Chara on 2002-08-07 14:29