In Excel, we all know that, there will be a moment in which we need the opposite the people usually need on usual Excel worksheets: this is the case of searching and filtering, from a dataset, only duplicates values, removing the unique ones.
So, now you have an Excel document in which there are some duplicate values in a column of your worksheet, and now, you want to remove non-duplicate values and keep only the duplicate records in the column. In this article we will talk about how to quickly and easily remove all but keeping the duplicate rows in Microsoft Excel.
For this scenario, to remove the non-duplicate rows, you need to create a formula helper column first, and then filter all the unique values based on your helper column, finally, delete the filtered unique values. Now we will have to execute the following steps:
Enter this formula =COUNTIF($A$2:$A$15, A2)=1 into a blank cell besides your data, such as cell B2, see screenshot:
In the above formula, A2:A15 is the column range you want to remove the unique values, you can change it as you need in your spreadsheet/worksheet.
Now drag the fill handle down to the cells that you want to apply this formula, False indicates the duplicate values and True stands for the unique values, see the following screenshot:
Now select the data range and click Data > Filter as in the following screenshot:
Click the filter drop-down in the new helper column B and uncheck FALSE option to just show the unique values of column A, and then click OK button, see screenshot:
After showing only the non-duplicate records, select the entire rows of these visible rows, and then click Home > Find & Select > Go To Special, in the Go To Special dialog box, select Visible cells only option, see the following screenshot:
Then click OK to close the dialog box, and only the visible rows have been selected as following screenshot shown:
And then you need to remove these visible rows only, put the cursor at the selected rows, right click to choose Delete Row from the context menu, see screenshot:
And only the visible rows are deleted at once, then you need to cancel the filter by clicking Data > Filter again to disable the Filter function, and you can see all the unique value rows have been removed, and only leave the duplicate records, see screenshot:
At last, you can delete the content of helper column B as you want.