Sumproduct in Macro

  • Thread starter Thread starter K
  • Start date Start date
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
 
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
 
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
 
Back
Top