ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sumproduct in Macro (https://www.excelbanter.com/excel-programming/431610-sumproduct-macro.html)

K[_2_]

Sumproduct in Macro
 
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

stanleydgromjr[_23_]

Sumproduct in Macro
 

K,

Lets start he

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


Have a great day,
Stan


--
stanleydgromjr
------------------------------------------------------------------------
stanleydgromjr's Profile: http://www.thecodecage.com/forumz/member.php?userid=503
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119801


K[_2_]

Sumproduct in Macro
 
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


Per Jessen[_2_]

Sumproduct in Macro
 
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


On 27 Jul., 15:59, K wrote:
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



K[_2_]

Sumproduct in Macro
 
thanks per jessen it worked



All times are GMT +1. The time now is 10:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com