PDA

View Full Version : MMult Headache - 5 Hours Lost!!!



ChloeRadshaw
12-15-2008, 05:33 PM
Guys,

I am completely lost here and spent the whole day banging my head against the wall:

Dim matrixA(0 to 0, 0 to 4) As Variant
'Populate matrix A

Dim matrixB(0 to 4, 0 to 0) As Variant
Populate matrix B

Dim z() As Variant
z = Application.worksheetfunction.mmult(matrixA, matrixB)

This does not work and returns an error saying cannot get the mmult function .....

I am really lost

Does anyone have any ideas / examples about how this works and what needs to happen?

The exact error messgae I got was
"Unable to get the MMult property of the WorksheetFunction class"

mikerickson
12-15-2008, 06:31 PM
In my testing, it worked fine with 1 based arrays and with 0 based.
However, the
Dim z() as Variant caused a "Cannot assign to array" error, that was fixed by Dim z as Vairiant

Also, if any of the matrix positions are empty, that caused a "MMult method failed" error. That can be fixed by either filling both matrices fully or by declaring them as Double.

Bob Phillips
12-16-2008, 01:20 AM
Why ever are you calling MMult from VBA? What are you trying to do (as afainst how you are trying to do it)?

ChloeRadshaw
12-16-2008, 02:43 AM
I am trying to multiply 2 d matrices....

SOmething is wrong with my code - Aargh!

Bob Phillips
12-16-2008, 06:45 AM
I am trying to multiply 2 d matrices....

SOmething is wrong with my code - Aargh!

Doh! I do know what MMULT is for, but why are you tryin g to multiply two matrices, whay are you doing it in VBA?