Reputation: 11
I have to look through my worksheet to find duplicate entries on the basis of two columns - column A and column D. If entries under both these columns match in any two given rows, then I consider them duplicated. In order to do this, I have been trying to sort the rows such that rows with matching entries under column A and column D appear one below the other. For example, if I have:
Col A Col B Col C Col D
ABC PQR 123 456
ABC XYZ 789 006
ABC BNM 376 456
ABC QWR 387 006
Preferably through VBA, I want to be able to put it in the format:
Col A Col B Col C Col D
ABC PQR 123 456
ABC BNM 376 456
ABC XYZ 789 006
ABC QWR 387 006
I am aware of how to sort by one column but not sure if there is a way to do it by two. There are more than 5000 rows in the worksheet and more than 50 columns and I would like to be able to sort these quickly for comparison.
Upvotes: 0
Views: 2301
Reputation: 203
Excel has built-in functions to help you with the issue (no VBA required).
Select the cells including your data and navigate to "Data - Sort & Filter - Sort". There you can add different levels of sorting (e.g. sort by Col A first, then by Col B, ...).
If the duplicates need to be removed this can be done directly as well. Select the cells including your data and navigate to "Data - Data Tools - Remove Duplicates". You can select the columns which need to match in order for Excel to remove the duplicates.
Upvotes: 1