YasserKhalil
10-30-2010, 01:07 PM
Hi everybody
I wrote the following code but I encountered an error at the line of sumproduct
Here's the code
Dim LastRow As Integer: Dim cel, rng, rngkind, rngsales As Range
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Range("D2:D" & LastRow)
Set rngkind = Range("Kind")
Set rngsales = Range("Sales")
Application.ScreenUpdating = False
For Each cel In rng
cel.Offset(0, 2) = Application.WorksheetFunction.SumProduct((rngkind = cel.Value) * (rngsales))
Next cel
Application.ScreenUpdating = True
I wrote the following code but I encountered an error at the line of sumproduct
Here's the code
Dim LastRow As Integer: Dim cel, rng, rngkind, rngsales As Range
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Range("D2:D" & LastRow)
Set rngkind = Range("Kind")
Set rngsales = Range("Sales")
Application.ScreenUpdating = False
For Each cel In rng
cel.Offset(0, 2) = Application.WorksheetFunction.SumProduct((rngkind = cel.Value) * (rngsales))
Next cel
Application.ScreenUpdating = True