title: Excel VBA, Invalid Qualifier, Array.Rank
body: <p>In the below code, <code>nX = xMat.Rank</code> returns the error "Invalid qualifier." Why? I'm using Excel 2010's built-in VBA editor:</p>
  
  <pre><code>Public Function polyReg(ByRef x() As Double, ByRef y() As Double) As Double()
    ' =============================
    Dim nX, nY, i, j As Integer
    Dim xMat() As Double
    nX = UBound(x)
    nY = UBound(y)
    ReDim xMat(1 To nX, 1 To order)
    ' =============================
    For i = 1 To order
      For j = 1 To nX
        xMat(j, i) = 1
      Next j
    Next i
    ' =============================
    nX = xMat.Rank
    ' =============================
    polyReg = y
    ' =============================
  End Function
  </code></pre>
  
  <p>I looked at a few related posts that failed to address my concern:</p>
  
  <p><a href="https://stackoverflow.com/questions/17032589/invalid-qualifier-for-string-add-in-outlook-vba">Invalid Qualifier for String.Add in Outlook VBA</a></p>
  
  <p><a href="https://stackoverflow.com/questions/7889653/invalid-qualifier-error-in-vba">https://stackoverflow.com/questions/7889653/invalid-qualifier-error-in-vba</a></p>
  
  <p><a href="https://stackoverflow.com/questions/13828796/invalid-or-unqualified-reference">Invalid or Unqualified Reference</a></p>
  
  <p>I have not found an answer to my question in Excel's VBA documentation.</p>