Runtime error 1004 on MMULT in VBA

lingkai

New Member
Joined
Jan 16, 2015
Messages
8
Hi,

Encountering this error on MMULT in VBA - would anyone be able to help me review and point out my mistakes please?

Runtime error 1004: Application-defined or object-defined error

Here's part of the code (pardon the clumsiness):


Range("B7").Select
CriteriaCount = Range(Selection, Selection.End(x1Down)).Rows.Count

'mmult code

Range("F10").Select
Do Until IsEmpty(ActiveCell.Value)

ActiveCell.Offset(0, CriteriaCount + 3).Value = WorksheetFunction.MMult(WorksheetFunction.MInverse(Range(Selection, Selection.End(x1Right))),Range(ActiveCell.Offset(0, 7), ActiveCell.Offset(CriteriaCount, 7)))
ActiveCell.Offset(1, 0.).Select

Loop


Thanks for your help!
 
Last edited:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to MrExcel.

Does it work if you change x1Right to xlToRight? Note that the second character is a lower case L not the number 1.
 
Upvote 0
Thanks Andrew.

Now I'm getting an error with the MInverse function:

Runtime error 1004: Unable to get the MInverse property of the WorksheetFunction class
 
Upvote 0
I see.

I just tried removing it and a new error occurred...

Unable to get the MMult property of the WorksheetFunction class.

ActiveCell.Offset(0, CriteriaCount + 3).Value = WorksheetFunction.MMult(Range(Selection, Selection.End(xlToRight)), Range(ActiveCell.Offset(0, 7), ActiveCell.Offset(CriteriaCount, 7)))
 
Upvote 0
Tried it, but somehow the formula wouldn't work:

ActiveCell.Offset(0, ColumnCount + 2).FormulaR1C1 = "'=MMULT(F10:" & ColumnLetter(5 + CriteriaCount) & "10,$M$10:$M$" & (9 + CriteriaCount) & ")"


ColumnLetter is a working function that pulls out the correct letter based on CriteriaCount.

This error occurs: Runtime error 1004: Application-defined or object-defined error

Cell F10 is the first of the single-row multi-column matrix.
Cell M10 is the first of the single-column multi-row matrix (same no. of rows as columns in the first matrix)
 
Upvote 0
Function ColumnLetter(ColumnNumber As Long) As String
Dim n As Long
Dim c As Byte
Dim s As String
n = ColumnNumber
Do
c = ((n - 1) Mod 26)
s = Chr(c + 65) & s
n = (n - c) \ 26
Loop While n > 0
ColumnLetter = s
End Function
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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