Jan Kalop
Active Member
- Joined
- Aug 3, 2012
- Messages
- 389
I have already VBA for random numbers, but I would like to add loop for how many times the random is run and the number foe sample is in Z25
"Sub TwentyfiveRandOf25()
Dim anArray(1 To 25) As Long
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To 25
anArray(i) = i
Next i
For i = 1 To 25
Randomize
Do
randIndex = (Rnd() * 25) + 1
Loop Until randIndex <= 25
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("Aa1:aa25").Value = Application.Transpose(anArray)
End Sub"
"Sub TwentyfiveRandOf25()
Dim anArray(1 To 25) As Long
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To 25
anArray(i) = i
Next i
For i = 1 To 25
Randomize
Do
randIndex = (Rnd() * 25) + 1
Loop Until randIndex <= 25
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("Aa1:aa25").Value = Application.Transpose(anArray)
End Sub"
Last edited: