Jan Kalop
Active Member
- Joined
- Aug 3, 2012
- Messages
- 389
What is wrong with bellow VBA code
Sub TwentyfiveRandOf25ONLY6()
Dim myVal As Integer
myVal = Range("AT36").Value
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To myVal
anArray(i) = i
Next i
For i = 1 To myVal
Randomize
Do
randIndex = (Rnd() * myVal) + 1
Loop Until randIndex <= myVal
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("az36").Resize(, 7).Value = anArray
End Sub
Sub TwentyfiveRandOf25ONLY6()
Dim myVal As Integer
myVal = Range("AT36").Value
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To myVal
anArray(i) = i
Next i
For i = 1 To myVal
Randomize
Do
randIndex = (Rnd() * myVal) + 1
Loop Until randIndex <= myVal
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("az36").Resize(, 7).Value = anArray
End Sub