VVA MMult question

gt213

Board Regular
Joined
Jul 5, 2016
Messages
61
In excel Im using the following array formula in cells D13:D15 {=MMULT(B8:D10,B13:B15)*B13:B15}, and i want to be able to replicate with VBA.

So far i think i have been able to get the first part ok with: Cont = Application.WorksheetFunction.MMult(Range1, Range2)

How do i then multiple this range by Range2, where the multiplication is done element wise?

Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try...

Code:
    Dim x As Variant
    Dim y As Variant
    Dim z As Variant
    Dim i As Long


    x = Application.MMult(Range("B8:D10"), Range("B13:B15"))
    
    y = Range("B13:B15").Value
    
    ReDim z(1 To UBound(x))
    
    For i = LBound(x, 1) To UBound(x, 1)
        z(i) = x(i, 1) * y(i, 1)
    Next i

    Range("D13:D15").Value = Application.Transpose(z)

Or, alternatively...

Code:
x = Application.Evaluate("MMULT(B8:D10,B13:B15)*B13:B15")

Hope this helps!
 
Last edited:
Upvote 0
Thanks for your help.

I actually ended up using .FormulaArray = "=MMult(Range1, Range2)*Range2"

I'm guessing this could be less efficient than your solution but it is useful for me to have the cells update anytime the values in either range change.
 
Upvote 0
Actually, the only reason I offered those two possible solutions is that in your original post you assigned the result of MMULT() to a variable. So your solution is fine, and might even be more efficient. In any case, I'm glad you found a solution. Thanks for our feedback.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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