VBA Multi dimensional Arrays used in multiple subs
<p>Ok so I am still trying to work out Arrays, I am learning quickly but still have one specific area I cannot get round which is frustrating.</p>

<p>I am trying to reference an array across multiple subs and when clicking a button, I am populating the array with strings and integers (which works fine). </p>

<p>The array is Publically declared.</p>

<p>How do I get the multi array to work across the different subs? I have tried using paramArray myArray as variant but I'm doing something wrong and respectfully requesting help here.</p>

<p>Please don't get caught up in the detail of my code below (its probably wrong), the way im adding the data here and what the data is isn't the question, its about how im using the array.</p>

<p>Thanks</p>

<pre><code>Public myArray()

Sub Main()
redim preserve myArray(10,5)
for z = 0 to 10
  for y = 0 to 5
     myArray(z,y) = 10 * Z + y
  Next y
Next z
End Sub

Sub Butn_Click()
  MsgBox myArray(0,1)
End sub

Sub testcode()
  MsgBox myArray(2,1)
end sub
</code></pre>