SOLVED

Duplicate management with condition

Occasional Contributor

Hello,

 

I would like to delete the duplicates (red ones) and keep those with the oldest date (green) with a macro on VBA.

 

minhhai91_0-1624627787615.png

 

Thank you in advance,

 

Frédéric

2 Replies
best response confirmed by minhhai91 (Occasional Contributor)
Solution

@minhhai91 

Sort the range on column E, from oldest to newest.

Click Remove Duplicates on the Data tab of the ribbon.

Select only column A (ID), then click OK.

 

As a macro:

Sub RemoveDups()
    Application.ScreenUpdating = False
    With Range("A1").CurrentRegion
        .Sort Key1:=Range("E1"), Header:=xlYes
        .RemoveDuplicates Columns:=1, Header:=xlYes
    End With
    Application.ScreenUpdating = True
End Sub
Thanks for your help