title: Excel VBA - assigning an array changes LBound and UBound
body: <p>I have a some very large data sets in Excel that I need to parse through - and doing it in an array is faster than looping through the data in the worksheet. Loading all of the data into an array is causing memory problems (the data sets ARE that large), so I plan on loading subsets of the data into an array, processing that, then loading another subset. I was hoping to use the array "feature" of defining the LBound and UBound to help me keep track of where I am in the worksheet. But I find that assigning the worksheet values to the array changes the bounds.
  The following code demonstrates the problem ...</p>
  
  <pre><code>    Sub myTest3()
      Dim myRange As Range
      Dim myArray As Variant
      Dim myOffset As Long
  
          myOffset = 10
          Set myRange = Worksheets("RawData").Range("A1").CurrentRegion
          ReDim myArray(myOffset To myRange.Rows.Count, myRange.Columns.Count)
          MsgBox LBound(myArray, 1) &amp; " to " &amp; UBound(myArray)
  
          Set myRange = myRange.Offset(myOffset, 0).Resize(myRange.Rows.Count - myOffset, myRange.Columns.Count)
  
          myArray = myRange.Value2
  
          MsgBox LBound(myArray, 1) &amp; " to " &amp; UBound(myArray)
  
      End Sub
  </code></pre>
  
  <p>The first MsgBox gives me "10 to 10931".
  The second MsgBox gives me "1 to 10921".</p>
  
  <p>Any ideas on maintaining the bounds on the array as I originally defined them? I know looping through the worksheet to make the assignment would do it, but it would be slow.</p>
  
  <p>Thanks in advance.</p>