Jan Kalop
Active Member
- Joined
- Aug 3, 2012
- Messages
- 389
This VBA formula is working perfectly, but I would like to be able control, the amount of numbers (in the case of bellow VBA formula is 28) to be random, from designated worksheet cell, for sample A1.
The same refers to choosing the Range (which in this sample is 6) to be able to control from designated worksheet cell, for sample B1.
"Sub TwentyfiveRandOf25ONLY6()
Dim anArray(1 To 28) As Long
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To 28
anArray(i) = i
Next i
For i = 1 To 28
Randomize
Do
randIndex = (Rnd() * 28) + 1
Loop Until randIndex <= 28
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("aq8").Resize(, 6).Value = anArray
End Sub"
Is this possible to rearrange the VBA formula to achieve that, and how?
The same refers to choosing the Range (which in this sample is 6) to be able to control from designated worksheet cell, for sample B1.
"Sub TwentyfiveRandOf25ONLY6()
Dim anArray(1 To 28) As Long
Dim i As Long
Dim randIndex As Long, temp As Long
For i = 1 To 28
anArray(i) = i
Next i
For i = 1 To 28
Randomize
Do
randIndex = (Rnd() * 28) + 1
Loop Until randIndex <= 28
temp = anArray(randIndex)
anArray(randIndex) = anArray(i)
anArray(i) = temp
Next i
Range("aq8").Resize(, 6).Value = anArray
End Sub"
Is this possible to rearrange the VBA formula to achieve that, and how?