Hi everybody
I wrote the following code but I encountered an error at the line of sumproduct
Here's the code
[VBA]Dim LastRow As Integer: Dim cel, rng, rngkind, rngsales As Range
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Set rng = Range("D2" & 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
[/VBA]