I have a huge list of data in excel (250.000+ rows) in the following format:
Number Value1 Date Value2
40325 1 21/01/11 18.10 2
65485 3 22/01/11 16.47 2
40325 9 25/01/11 19.00 0
70912 8 27/01/11 16.43 2
I need to remove duplicate rows based on column 1 (Number), and have no problem doing this using "Data/Remove Duplicates" in Excel, but I need to make sure that I remove the row with the oldest date, and keep the newest, based on column 3 (Date).
In the example above, I would need to remove row 1 and keep row 3, since row 3 is the newest.
I have 4.800 rows with duplicates, so a manual sorting/removing would be a very time consuming job.
Any good suggestions? And tricks to help me out? Thanks a lot in advance 🙂
Best Answer
The trick is to sort your table before using
Remove duplicates
. Excel always keeps the first data set of a duplicated row. All consecutive rows are removed.In your case:
Set up a helper column and fill it with numerical values. Start by 1 and use autofill till the end of our table
Make sure your date column is formatted as date and Excel recognize them as date. Otherwise your sorting wouldn't work
Choose
Custom sort
(depends on your Excel version). Sort your whole table by date column from Newest to Oldest. That's the important partUse
Remove duplicates
and select only your Number column which holds your criteria to check for duplicates. Deselect all other columnsChoose
Custom Sort
again and sort your table by that Helper column we have added at the beginning to get your original row order back