Sumproduct in Macro

K

K

Sub DD()
Dim c As Range
Lastcl = Cells(Rows.Count, "A").End(xlUp).Row
For Each c In Range("N2:N" & Lastcl).Cells
c.Value = WorksheetFunction.SumProduct(--(Range("M2:M" & Lastcl)), --
(Range("H2:H" & Lastcl)))
Next c
End Sub

above macro doesnt work please help
 
S

stanleydgromjr

K,

Lets start here:

If you were to manually enter your SUMPRODUCT formula in cell N2, wha
would the formula look like?


Have a great day,
Sta
 
K

K

it would be
=SUMPRODUCT(($M$2:$M$206=M2)*($H$2:$H$206))

please note that i am trying to put this formula in sheet from another
sheet
 
P

Per Jessen

Hi

Try this:

Sub DD()
Dim LastCl As Long
LastCl = Cells(Rows.Count, "A").End(xlUp).Row
Range("N2").Formula = "=SUMPRODUCT(($M$2:$M$" & LastCl & "=M2)*($H$2:$H
$" & LastCl & "))"
Range("N2:N" & LastCl).FillDown

End Sub


Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top