Sub Test()
Dim Lr As Long, Lr2 As Long
Lr = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:B" & Lr).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J1:K1"), Unique:=True
Lr2 = Range("J" & Rows.Count).End(xlUp).Row
Range("J1:K" & Lr2).Sort key1:=Range("J1"), order1:=xlAscending, Key2:=Range("K1"), Order2:=xlAscending, Header:=xlYes
Range("L1:M1").Value = Array("Amount", "Count")
Range("L2:L" & Lr2).Formula = "=SUMIFS($F$2:$F$" & Lr & ",$A$2:$A$" & Lr & ",J2,$B$2:$B$" & Lr & ",K2)"
Range("M2:M" & Lr2).Formula = "=CountIFS($A$2:$A$" & Lr & ",J2,$B$2:$B$" & Lr & ",K2)"
Range("J1:M" & Lr2).AutoFilter Field:=4, Criteria1:="=1", Operator:=xlAnd
Range("J2:M" & Lr2).SpecialCells(xlCellTypeVisible).ClearContents
Range("J1:M" & Lr2).AutoFilter
Range("J1:M" & Lr2).Sort key1:=Range("J1:J" & Lr2), order1:=xlAscending, Header:=xlYes
End Sub