Creating an Array from a Range in VBA
<p>I'm having a seemingly basic problem but can't find any resources addressing it.</p>

<p>Simply put, I just want to load the contents of a Range of cells (all one column) into an Array.</p>

<p>I am able to accomplish this by means of </p>

<pre><code>DirArray = Array(Range("A1"), Range("A2"))
</code></pre>

<p>But for some reason, I cannot create the array when expressed this way:</p>

<pre><code>DirArray = Array(Range("A1:A2"))
</code></pre>

<p>My real Range is much longer (and may vary in length), so I don't want to have to individually enumerate the cells this way. Can anyone tell me how to properly load a whole Range into an Array?</p>

<p>With the latter code:</p>

<pre><code>MsgBox UBound(DirArray, 1)
</code></pre>

<p>And</p>

<pre><code>MsgBox UBound(DirArray)
</code></pre>

<p>Return 0, whereas with the former they return 1.</p>