I'm not sure why you are using SUMPRODUCT rather than SUMIF, but you could use:
Sub SumCharges() Dim ws As Worksheet Dim LastRow As Long Dim ws1 As Worksheet Dim LastRow1 As Long Dim tAmount As Range Dim R As Long 'Used for Rows Dim sFormula As String Set ws = ThisWorkbook.Worksheets("Vehicle Listing") LastRow = ws.Range("A65536").End(xlUp).Row Set ws1 = ThisWorkbook.Worksheets("Event Repair - OK") LastRow1 = ws1.Range("A65536").End(xlUp).Row Set tAmount = ws.Range("P2:P" & LastRow) For R = 2 To LastRow 'Used for populating Rows If Cells(R, 1).Value <> "" Then sFormula = "sumproduct((A2:A" & LastRow & "=A2)*P2:P" & LastRow & ")" Cells(R, 4).Value = ws.Evaluate(sFormula) End If Next R End Sub




Reply With Quote