# Run-time error '1004': Unable to get the MInverse property of the WorksheetFunction class

#### mwdhont

##### New Member
Dear all,

I would like to solve a set of linear equations with VBA. I need to do this with VBA, because the number of equations is dynamic.
While executing I get the error as metioned in the title and the last line is highlighted. I read a lot about the error, but I couldn't find my mistake.

Someone who has an idea?

Michael

ps: I'm not sure if it's really necessary to copy all the values in newly defined matrices? Maybe it's possible to work with a command which select the matrix directly from the spreadsheet?

This is the code I made:

Code:
``````Sub Test()
With Application.WorksheetFunction
Dim N As Integer
N = Range("I2").Value

'Initialize the matrix A

Dim A() As Variant
ReDim A(9 + 2 * N, 9 + 2 * N)
For Index = 0 To 9 + 2 * N
For m = 0 To 9 + 2 * N
A(Index, m) = Cells(97 + i, 58 + m)
Next m
Next Index

'Initialize the rhs of the equations
Dim B() As Variant
ReDim B(9 + 2 * N)
For Index = 0 To 2 * N + 9
B(Index) = Cells(3 + i, 58 + Iteration)
Next Index

'Compute the solution
Dim Corrections As Variant
Corrections = .MMult(.MInverse(A), B)

End With
End Sub``````

### Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Replies
4
Views
62
Replies
2
Views
220
Replies
10
Views
94
Replies
6
Views
294
Replies
2
Views
65

1,136,210
Messages
5,674,420
Members
419,508
Latest member
trinstrick

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back