I have a spreadsheet with two columns, a name and a value. The name is repeated several times with different values, for instance:
Name – 1
Name – 2
Name – 3
etc.
I am looking for a formula that will go through the spreadsheet and delete all duplicate instances of the name column, saving the one with the second highest value. So if I input a spreadsheet like the one above, it would save the row "Name – 2" and delete the others. Is this possible?
EDIT: The spreadsheet has 6000+ values, so I'd prefer a solution that's as automated as possible. I was thinking something like:
- Sort values by name, then value.
- Formula that deletes duplicate rows with lowest values.
- Formula that deletes all rows but lowest values.
Best Answer
You can get what you want with a helper column and a filter.
Step 1: Helper column
Add a column to your table with the following formula, where the names are in
A2:A18
and the values are inB2:B18
.This formula will return
TRUE
for the rows you want to keep, i.e., with the second highest value for duplicate names, and any non-duplicate names (liked
in my example below). If by chance you DON'T want to keep non-duplicate rows, you can use the following formula instead.Step 2: Filter
Simply filter the entire table for rows that are
TRUE
in the helper column.If filtering is not enough, and you really need to delete the other data, you can just copy and paste the filtered result to another table, and then after deleting the original table, you can paste in your clean copy.