Dim i As Integer
i = Range("A1").End(xlDown).Row
Application.ScreenUpdating = False
Range("D1").Select
ActiveCell.FormulaR1C1 = "Quantity"
Range("D2").Select
ActiveCell.FormulaR1C1 = _
"=SUMPRODUCT((RC[-3]=R2C1:R" & i & "C1)*(RC[-2]=R2C2:R" & i & "C2),R2C3:R" & i & "C3)"
Range("D2").Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("C2").Select
Application.CutCopyMode = False
Selection.EntireColumn.Delete
Range("A1").Select
Range("A1:C" & i).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"D1"), Unique:=True
Range("A1:C1").Select
Selection.EntireColumn.Delete
Range("A1").Select
Application.ScreenUpdating = True
End Sub
|