I have a VBA script error out with "Type mismatch" on the Application.WorksheetFunction MInverse line. How else am I suppose to calculate a matrix inverse? What is the type mismatch? Both arrays are the same size and the matrix defined is invertible.
Option Explicit
Option Base 1
Function CalcB()
Dim A() As Double
Dim B() As Double
ReDim A(1 To 2, 1 To 2)
ReDim B(1 To 2, 1 To 2)
A = CalcA()
B = Application.WorksheetFunction.MInverse(A)
Range("A1:B2") = B
End Function
Private Function CalcA()
Dim aAr() As Double
ReDim aAr(1 To 2, 1 To 2)
aAr(1, 1) = 2.8
aAr(2, 2) = 7.3
aAr(1, 2) = 5.7
aAr(2, 1) = 1.7
CalcA = aAr
End Function
Option Explicit
Option Base 1
Function CalcB()
Dim A() As Double
Dim B() As Double
ReDim A(1 To 2, 1 To 2)
ReDim B(1 To 2, 1 To 2)
A = CalcA()
B = Application.WorksheetFunction.MInverse(A)
Range("A1:B2") = B
End Function
Private Function CalcA()
Dim aAr() As Double
ReDim aAr(1 To 2, 1 To 2)
aAr(1, 1) = 2.8
aAr(2, 2) = 7.3
aAr(1, 2) = 5.7
aAr(2, 1) = 1.7
CalcA = aAr
End Function