Duplicate values in Excel can be annoying, but fortunately, there are several methods for finding and removing them. We recommend making a backup copy of your Excel sheet before removing the duplicates. Let’s look at how to find, count, and remove duplicate values in Excel.
- 1. Use the Remove Duplicates Button
- 2. Find Duplicate Data Using Conditional Formatting
- 3. Remove Duplicates Using Conditional Filter
- 4. Find Duplicate Values Using a Formula
- 5. Count Number of Duplicates Using a Formula
- 7. Remove Duplicate Data Using Advanced Filters
- 8. Remove Excel Duplicates Using Power Query
1. Use the Remove Duplicates Button
Excel comes with a native button to remove duplicate values.
- Select the column where you would like to remove the duplicates.
- Go to the “Data” tab and click the “Remove Duplicates” button.
- The Duplicates warning box will appear, letting you customize your selection.
- Select the “Continue with the current selection” option to remove duplicates from the currently selected data set.
- To include more columns in the list, select “Expand the selection.”
- Press the “Remove duplicates” button in both cases.
- Keep the box checked next to the columns containing the duplicates and uncheck that you want to keep them.
- Make sure the box next to “My data has headers” is selected. This will keep the first sets of data for duplicate values while removing their subsequent entries.
- Click the OK button. Excel will remove all duplicate values and provide a summary of how many duplicate and unique values were found.
2. Find Duplicate Data Using Conditional Formatting
This method of removing duplicates is based on conditional formatting and will help you find duplicate values without deleting them.
- In your Excel sheet, select the data that contains duplicates. It can be a column or the entire table.
- Go to the “Home” tab and click on “Conditional Formatting.” The duplicate values will be highlighted.
- Choose “Highlight Cell Rules” followed by “Duplicate Values.”
- The “Duplicate Values” pop-up will appear, allowing you to change the color of duplicate values.
- Click on the ‘Duplicate” drop-down box and select “Unique” if you want to see unique values instead.
- Click on “OK.”
3. Remove Duplicates Using Conditional Filter
With the duplicates highlighted, you can either use filters to remove them or use the method shown above.
- To activate the Filter operation, go to “Home tab → Sort & Filter → Filter.”
- A drop-down box will appear next to the column headers in your data. Click on the drop-down box on the column where you would like to filter duplicates.
- Select “Filter by color” from the menu. Choose the color of unique values to keep them in your sheet and remove the duplicates.
Now your sheet will only show unique values. Be careful as this method removes all the duplicate values including the first one.
To copy the unique values, select the data set and use the Alt + ; keyboard shortcut to select only the visible rows, then use the Ctrl + C shortcut to copy the visible rows and paste them wherever required.
4. Find Duplicate Values Using a Formula
Duplicates in a column can also be found using Excel formulas. The most basic formula for detecting duplicate entries is
=COUNTIF(Range, Criteria) >1, where the range can be the entire column or a subset of rows.
Create a new column and enter one of the below commands in the new column.
- Use the formula
=COUNTIF(D:D, D2) >1for a full column, where D is the column name and D2 is the topmost cell.
- For selected rows, use the formula
=COUNTIF($D$2:$D$10, $D2) >1,where the first set represents the selected rows, and D2 is the topmost cell. Please note that the range must be preceded by the dollar ($) sign, otherwise the cell reference will change when you drag the formula.
Drag the fill handle to use the command in the other rows. The formula will show “True” for duplicate values and “False” for unique values.
If you want to display some other text than True or False, you must enclose the COUNTIF formula in the IF function. So the formula will become
=IF(COUNTIF($D$2:$D$10, $D2) > 1, "Duplicate”, “Single”).
If you want unique values to show a blank cell, use the formula
=IF(COUNTIF($D$2:$D$10, $D2) > 1, “Duplicate”, “”).
5. Count Number of Duplicates Using a Formula
You can use the above formula without the
> 1 text to count the number of duplicates in a column. The two formulas will become
=COUNTIF($D$2:$D$10, $D2) and
=COUNTIF(D:D, D2). Enter in the new column for it to display how many times each item appears in the data.
6. Remove Duplicate Values Using a Formula
Once you have found the duplicate values or the duplicate count, use the filter method to remove duplicates and retain unique values.
- Go to “Home tab -> Sort & Filter -> Filter” to enable the filter drop-down box on the column header.
- Click it and keep the box checked next to the value you want to keep. It should be “Unique” for the finding duplicates method and “1” for Counting duplicates. Doing so will hide the duplicate values and display unique values.
- Select the visible rows using the Alt + ; shortcut.
7. Remove Duplicate Data Using Advanced Filters
- Go to the “Data” tab and click on “Advanced.”
- The “Advanced Filter” pop-up window will open.
- Select the “Filter the list, in-place” option if you want to hide the duplicates on the same data set. You can manually copy-paste the unique values later to a different place in the same sheet or to a different sheet.
- With this option selected, select the list of columns. They will automatically show up in the “List range” field. Leave “Criteria range” blank.
- Check the box next to “Unique records only” and hit “OK.”
- That will show unique values in your data. Use the Alt + ; shortcut to select visible rows only if you want to perform any action on them.
- On the contrary, select “Copy to another location” if you want Excel to automatically copy the unique values to a different place in the same sheet.
- Select the “List range” first. You can keep the “Criteria range” blank.
- Click once on the “Copy to” field and select the rows on your sheet where you want to copy the unique data.
- Make sure the box next to “Unique records only” is checked.
8. Remove Excel Duplicates Using Power Query
Power Query also helps to remove duplicate values in Excel as shown below.
- Select the values where you want to remove duplicates.
- Go to the “Data” tab and click on “From Table/Range.”
- The “Power Query” editor will open. Select the columns and right-click on the selected column header. Choose “Remove duplicates” from the menu.
- If you want to remove duplicates from the entire table, click on the “Table” button at the top-left corner and choose “Remove Duplicates.” Alternatively, select “Keep duplicates” to show only the duplicate entries and remove the rest.
- Click on “Close and Load” at the top to open the table in the same sheet.
9. Using Pivot Tables
You can use Pivot tables to display only the unique values in your data, thus removing the duplicate entries.
- Start by creating a Pivot table by selecting a cell inside your data.
- Go to “Insert → Pivot table.” Select “From Table/Range.”
- The PivotTable from the table or range pop-up will open.
- Select the table or range where you want to hide duplicate values, for it to automatically show up in the “Table/Range” field.
- Select whether the PivotTable should be placed in the same worksheet or in a new worksheet.
- Click “OK.”
- You will be greeted by the “PivotTable Fields” sidebar. Drag the columns where you to extract unique values to the “Rows” section.
You will need to format the PivotTable to show it in a tabular form. For that, go to the Data tab and perform the following steps:
- Click on “Report Layout → Show” in tabular form.
- Go to “Subtotals → Do not show subtotals.”
- Click on “Report Layout → Repeat all item labels.”
- Under “Grand Totals,” select “Off” for rows and columns.
You will get a Pivot table with unique values in a tabular form.
Excel in Excel
Our latest tutorials delivered straight to your inbox