I have inherited some VBA code in Excel 2016 - when the code is run, 500 users are input one by one, and a random number assigned to each one.
As far as I understand, the code uses Randomize and Rnd (-1) to set the same starting seed each time, so that every time 500 users are input the same 500 random numbers are used.
I need to output a list of these 500 random numbers.
So far I have used this code:
However, this outputs 500 random copies of the SAME random number! How do I get the 500 different random numbers?
Many thanks
As far as I understand, the code uses Randomize and Rnd (-1) to set the same starting seed each time, so that every time 500 users are input the same 500 random numbers are used.
I need to output a list of these 500 random numbers.
So far I have used this code:
Code:
Private Sub CommandButton1_Click()
Randomise_Range (Sheets("Sheet1").Range("A1:A500"))
End Sub
Sub Randomise_Range(Cell_Range As Range)
Dim Cell
Application.ScreenUpdating = False
For Each Cell In Cell_Range
Cell.Value = Rnd(-1)
Randomize (1)
Next Cell
Application.ScreenUpdating = True
End Sub
However, this outputs 500 random copies of the SAME random number! How do I get the 500 different random numbers?
Many thanks