VBA what is wrong

Status
Not open for further replies.

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
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
If you debug/compile or add "Option Explicit" you will find that you have not declared "anArray".
You did not say what appeared to be the problem you were having, so I am just guessing.
 
Upvote 0
If you debug/compile or add "Option Explicit" you will find that you have not declared "anArray".
You did not say what appeared to be the problem you were having, so I am just guessing.


so what have to be done to make it working....sorry but I don't know anything about how to fix this
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top