Reputation: 1306
In the below code, nX = xMat.Rank
returns the error "Invalid qualifier." Why? I'm using Excel 2010's built-in VBA editor:
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
I looked at a few related posts that failed to address my concern:
Invalid Qualifier for String.Add in Outlook VBA
https://stackoverflow.com/questions/7889653/invalid-qualifier-error-in-vba
Invalid or Unqualified Reference
I have not found an answer to my question in Excel's VBA documentation.
Upvotes: 0
Views: 1538
Reputation: 1306
I'm not a VB expert. If my answer below is incorrect, someone please notify me:
Visual Basic <> Visual Basic for Applications (Excel)... This is a hard lesson for me to learn. The Array.Rank function exists in VB but does not exist in VBA (Excel). What. A. Shame.
I'm tempted to ask another question with a similar answer, just because I know it will confound other programmers unfamiliar with VB and VBA. Is there any policy against asking questions to which you know the answer? (Topic of theoretical question: Try/Catch? Only VB. VBA (Excel) uses On Error.)
Upvotes: 1