I'm trying to inverse a matrix into an Excel macro with the function MInverse.
I wrote a code but it doesn't work.
The problem is that i want to solve a system of linear equation but the number of equation must be an input of the problem. So the dimension of the matrix had to be a variable.
I wrote this code but at the end it gives me an error "1004" in the last line.
Any help is welcome
Thanks a lot
I wrote a code but it doesn't work.
The problem is that i want to solve a system of linear equation but the number of equation must be an input of the problem. So the dimension of the matrix had to be a variable.
I wrote this code but at the end it gives me an error "1004" in the last line.
Any help is welcome
Thanks a lot
Code:
Dim Z As Integer
Z = (Range("D2") / 2) + 2
Dim A() As Double
ReDim A(1 To Z, 1 To Z)
Dim InvA As Double
ReDim InvA(Z, Z)
Dim B() As Double
ReDim B(Z)
Dim riga As Integer
Dim colonna As Integer
For riga = 1 To Z
For colonna = 1 To Z
A(riga, colonna) = Sheets("Coeff. NR").Cells(riga + 5, colonna + 2).Value
Next colonna
Next riga
InvA = Application.WorksheetFunction.MInverse(A)
Last edited: