Sub Keep_duplicates()
Dim sh As Worksheet, ky As Variant, lr As Long, lc As Long, i As Long, a
Dim n As Long, l2 As Long, j As Long, m As Long, r As Range
Application.SheetsInNewWorkbook = 1
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'
Set sh = ActiveSheet
If sh.AutoFilterMode Then sh.AutoFilterMode = False
lr = sh.Range("A" & Rows.Count).End(xlUp).Row
lc = sh.Cells(3, Columns.Count).End(xlToLeft).Column
sh.Range("A3", sh.Cells(lr, lc)).Sort key1:=sh.Range("C3"), order1:=xlDescending, Header:=xlNo
a = sh.Range("A3:A" & lr)
With CreateObject("scripting.dictionary")
For i = 1 To UBound(a)
.Item(a(i, 1)) = Empty
Next
For Each ky In .Keys
n = WorksheetFunction.CountIf(Range("A3:A" & lr), ky)
If n > 12 Then
m = n - 12
sh.Range("A3").AutoFilter 1, ky
l2 = sh.Range("A" & Rows.Count).End(xlUp).Row
Set r = Range("A" & l2 + 1)
For j = l2 To 3 Step -1
If m = 0 Then Exit For
If sh.Range("A" & j).EntireRow.Hidden = False Then
Set r = Union(r, Range("A" & j))
m = m - 1
End If
Next
r.EntireRow.Delete
End If
Next
End With
If sh.AutoFilterMode Then sh.AutoFilterMode = False
sh.Range("A3", sh.Cells(lr, lc)).Sort key1:=sh.Range("A3"), order1:=xlAscending, Header:=xlNo
End Sub