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

mwdhont

New Member
Joined
Aug 1, 2016
Messages
6
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?

Thanx in advance,

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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top