(Solved) – Excel – VBA for Duplicates (specific need)

(solved)-–-excel-–-vba-for-duplicates-(specific-need)

I’ve been scouring stackoverflow and haven’t found what I am looking for. Which is frustrating because I know I can’t be the only one who has come across this.

I have an excel spreadsheet with 26k rows — and I need to purge all rows where column D and E have same values — except I want to keep at most 10 rows and purge rest. In some instances there will only be 3 duplicate rows so those can stay.

Here is example of my spreadsheet.

 ------ ------- -------- --------- --------- 
| Code | Local | Number | Place A | Place B |
 ------ ------- -------- --------- --------- 
| A    | 558   | 25     | DEW     | ABE     |
 ------ ------- -------- --------- --------- 
| A    | 485   | 14     | DEW     | FXD     |
 ------ ------- -------- --------- --------- 
| A    | 658   | 85     | DEW     | ABE     |
 ------ ------- -------- --------- --------- 
| A    | 225   | 68     | ABE     | FXD     |
 ------ ------- -------- --------- --------- 
| A    | 1     | 56     | ABE     | FXD     |
 ------ ------- -------- --------- --------- 
| A    | 47    | 412    | DEW     | CDE     |
 ------ ------- -------- --------- --------- 

Imagine I had 15 rows where Place A and Place B were DEW and ABE — I would want to delete 5 of those. I don’t care what 5, just 5 have to go and I need to be left with 10.

Leave a Reply

Your email address will not be published. Required fields are marked *