Matrix inverse with MInvers, help please.

Joined
Apr 29, 2010
Messages
2
Reaction score
0
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



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:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top