Jan Kalop
Active Member
- Joined
- Aug 3, 2012
- Messages
- 389
I have VBA formula which is working perfectly, but only the results are all in one column and I would like them to appear in one specific row.
"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("ck5:ck11").Value = Application.Transpose(anArray)
End Sub"
When I change the array from ck5:ck11 to for sample to CK5:CR5 the formula do not work. What have to be change to get the result in row?
"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("ck5:ck11").Value = Application.Transpose(anArray)
End Sub"
When I change the array from ck5:ck11 to for sample to CK5:CR5 the formula do not work. What have to be change to get the result in row?