title: Array passed to Sub Procedure but returned with wrong dimension size
body: <p>I have an issue with the code below. Appreciate your helps.</p>
  <p>I have created a sub (&quot;GetListItems&quot;) that receives an Array as an argument. The sub populates the array with the data from a group of Non-contiguous Ranges in the first sheet of my excel file. Sub performs as expected and the array in the sub, after the date is assigned to it, has 2 dimensions with correct number of columns in the second dimension.</p>
  <p>However, When I pass an array to this sub which is by reference, the returned array has only 1 dimension. I have been struggling with this the whole day and do not understand the reason. Appreciate your help.</p>
  <pre><code>Sub GetListItems(ByRef arrArray() As Variant)
  
  Dim WS As Worksheet
  Dim LastRow As Integer
  Dim SelectedCols As String
  
  ' Initialize our variable and get the last row in the database
  Set WS = Worksheets(&quot;Database&quot;)
  LastRow = WS.Cells(WS.Rows.Count, 1).End(xlUp).Row
  
  ' select ranges for copying
  SelectedCols = &quot;A1:A&quot; &amp; LastRow &amp; &quot;, C1:C&quot; &amp; LastRow &amp; _
               &quot;, F1:F&quot; &amp; LastRow &amp; &quot;, H1:H&quot; &amp; LastRow &amp; _
               &quot;, V1:V&quot; &amp; LastRow &amp; &quot;, W1:W&quot; &amp; LastRow &amp; _
               &quot;, X1:X&quot; &amp; LastRow &amp; &quot;, Z1:Z&quot; &amp; LastRow
  
  'Copy and paste data from defined range
  WS.Range(SelectedCols).Copy
  Set WS = Worksheets.Add(, Sheets(Sheets.Count))
  With WS
      .Visible = xlSheetHidden
      .Paste WS.Range(&quot;A1&quot;)
  End With
  
  ' Initialize array
  arrArray = WS.Range(&quot;A1&quot;).CurrentRegion
  
  ' Delet the hidden sheet
  With Application
      .CutCopyMode = False
      .DisplayAlerts = False
      WS.Delete
      .DisplayAlerts = True
  End With
  
  End Sub
  </code></pre>
  <p>==============================================================</p>
  <pre><code>Sub test()
  
  Dim MyArray() As Variant
  Dim Dimension As Integer, Temp As Integer
  Application.Run &quot;GetListItems&quot;, MyArray
  
      On Error GoTo Err
  Do While True
      Dimension = Dimension + 1
      Temp = UBound(MyArray, Dimension)
  Loop
  
  Err:
  MsgBox &quot;MyArray variable has &quot; &amp; Dimension &amp; &quot; dimensions!&quot;, vbInformation And vbOKOnly
  
  
  End Sub
  </code></pre>