[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]
[color=darkblue]Sub[/color] KeepLastTwoEntries()
[color=darkblue]Dim[/color] LastRow [color=darkblue]As[/color] [color=darkblue]Long[/color]
[color=darkblue]Dim[/color] LastCol [color=darkblue]As[/color] [color=darkblue]Long[/color]
[color=darkblue]Dim[/color] i [color=darkblue]As[/color] [color=darkblue]Long[/color]
Application.ScreenUpdating = [color=darkblue]False[/color]
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Range("A1", Cells(LastRow, LastCol)).Sort _
key1:=Range("A1"), order1:=xlAscending, _
key2:=Range("B1"), order2:=xlDescending, _
key3:=Range("C1"), order3:=xlDescending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTop[color=darkblue]To[/color]Bottom
Range(Cells(2, LastCol + 1), Cells(LastRow, LastCol + 1)).FormulaR1C1 = "=RC1&""#""&RC2"
[color=darkblue]For[/color] i = LastRow To 2 [color=darkblue]Step[/color] -1
[color=darkblue]If[/color] WorksheetFunction.CountIf(Range(Cells(2, LastCol + 1), Cells(i, LastCol + 1)), Cells(i, LastCol + 1)) > 2 [color=darkblue]Then[/color]
Rows(i).Delete
[color=darkblue]End[/color] [color=darkblue]If[/color]
[color=darkblue]Next[/color] i
Columns(LastCol + 1).ClearContents
Application.ScreenUpdating = [color=darkblue]True[/color]
MsgBox "Completed...", vbInformation
[color=darkblue]End[/color] [color=darkblue]Sub[/color]