title: Excel VBA Overflow Error with Dynamic Array
body: <p>I'm getting an Overflow area in the following sub, and I can't figure out why. Stepping through the code, lRows and lCols gets set to the correct values, and the redims set the correct ranges on the arrays, but it fails when I try to assign the range values to the array (on line: arrData = rng.value). My rows do often go up to around 90,000+, but I have everything as long, so I would think that wouldn't be a problem...</p>
  
  <pre><code>Sub test()
  Dim arrData() As Variant
  Dim arrReturnData() As Variant
  Dim rng As Excel.Range
  Dim lRows As Long
  Dim lCols As Long
  Dim i As Long, j As Long
  
  lRows = ActiveSheet.Range("A" &amp; Rows.Count).End(xlUp).Row
  lCols = ActiveSheet.Range("A1").End(xlToRight).Column
  
  ReDim arrData(1 To lRows, 1 To lCols)
  ReDim arrReturnData(1 To lRows, 1 To lCols)
  Set rng = ActiveSheet.Range(Cells(1, 1), Cells(lRows, lCols))
  arrData = rng.value ' Overflow error on this line
  For j = 1 To lCols
      For i = 1 To lRows
          arrReturnData(i, j) = Trim(arrData(i, j))
      Next i
  Next j
  
  rng.value = arrReturnData
  End Sub
  </code></pre>