Assign Cell Value to Array Dimension

limerind

New Member
Joined
Mar 21, 2012
Messages
5
This forum is a Godsend for people like me trying to teach VBA to themselves. Thanks in advance for any help.

I'm trying to run a Monte Carlo simulation through a four dimensional array, and I'd like to do so in a way that's at least a little user friendly. So I've set up a worksheet with some user-defined parameters.

The Simulation works like this: Each entrant in a group makes 10 decisions (dimension 1 of the array). There are anywhere between 50 and 5000 entrants in a given contest (dimension 3 of the array), and I want to simulate running the contest anywhere between 50 and 5000 iterations (dimension 4 of the array). Dimension 2 of the array are the information and calculations defining the decision. Now I'm trying to use those parameters to define the array, and I'm being told that array dimensions need to be constants.

The nascent code is below:

Code:
Public Sub RunDataGenerator()
Dim Entrants As Integer
Dim Iterations As Integer
Entrants = Sheets("Information").Range("C4").Value
Iterations = Sheets("Information").Range("C5").Value

Dim PicksArray(9, 7, Entrants, Iterations) As Double

I'm looking for a way to define the array based on the entries in Cells C4 and C5 of the Information Sheet. I have also tried ReDim with no success.

Also, making the Array global would be a tremendous help, though I can work around it if it's not.
 

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