title: Matrix dynamic sizing with ReDim Preserve
body: <p>Please, give a look at the following VBA subroutine:</p>
  
  <pre><code>Sub mySub()
  
      Dim i As Integer
      Dim j As Integer
      Dim myArray() As Double
  
      For i = 1 To 10
          For j = 1 To 5
              ReDim Preserve myArray(1 To i, 1 To j)
              myArray(i, j) = i + j
          Next j
      Next i
  
  End Sub
  </code></pre>
  
  <p>This small example is intended to declare a 2-dimensional array and to dinamically resize it via <code>ReDim Preserve</code>: at the end of the loop it should return a 2-dimensional array whose each element is the sum of the row and column indexes.</p>
  
  <p>Nevertheless, this line of code returns an error due to subscript out of range:</p>
  
  <pre><code>ReDim Preserve myArray(1 To i, 1 To j)
  </code></pre>
  
  <p>Do I need to <code>ReDim</code> the array before using <code>ReDim Preserve</code>? Even doing that, the issue is still there.</p>