Hi, Elaine,
for the sample the results differ from the sheet Result due to the reason of mulitple Customers but you could at least try and test it to see if the code comes near to what you expect. Please try the code on a copy of the data or the sample:
Sub EF_956682()
Dim wsData As Worksheet
Dim lngCounter As Long
'Set wsData = Sheets("DATA")
Set wsData = ActiveSheet
With wsData
For lngCounter = .Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(.Range("B2:B" & lngCounter), .Cells(lngCounter, "B")) > 1 Then
If WorksheetFunction.CountIf(.Range("B:B"), .Cells(lngCounter, "B")) > _
WorksheetFunction.CountIf(.Range("B2:B" & lngCounter), .Cells(lngCounter, "B")) Then
Rows(lngCounter).Delete
Else
.Cells(lngCounter, "N").Value = WorksheetFunction.SumIf(.Range("B:B"), .Cells(lngCounter, "B"), Range("N:N"))
End If
End If
Next lngCounter
End With
Set wsData = Nothing
End Sub
Ciao,
Holger
Bookmarks