How to Remove Duplicates in Excel (9 Simple Ways)

Removing duplicates in Excel means keeping unique values and erasing the multiple instances.
In this Excel tutorial, you will learn how to remove duplicates in Excel with different useful tools and functions.

Multiple instances of duplicate values and rows occur while performing multiple tasks with very large worksheets or consolidating several sheets into an extensive one. You may also enter information multiple times mistakenly into a dataset. So, you need to erase them once you find those duplicates.

Suppose we have a dataset containing Employee ID, Employee Name, Joining Year, and Salary. There are some duplicate rows. Now we will delete duplicate rows using the Remove Duplicates command.

An overview of how to remove duplicates in Excel

This Excel tutorial covers:

  • Use of the Remove Duplicates command for single and multiple columns
  • Erase of duplicate rows from a Table with the Remove Duplicates command
  • Application of Advanced filter to remove duplicates
  • Use of UNIQUE function to bring out only unique values
  • Removal of duplicates but keeping 1st instances with IF-COUNTIF formula
  • Application of Excel formula and Filter tool to remove duplicates
  • Removal of duplicates based on criteria with the Advanced Filter tool
  • Use of Power Query for removing duplications
  • Application of VBA Macro to remove duplicates from any selection.
📒Note: We have used Microsoft 365 while preparing the dataset for this tutorial. You can apply the mentioned methods in versions from Excel 2007 onwards.


1. Using Remove Duplicates Command to Erase Duplicates in Excel

We will remove duplicates from a single or multiple columns using the Remove Duplicates command. The Remove Duplicates command is the built-in veteran Excel tool to erase duplicate instances. It can be useful for removing duplicates from both single and multiple columns.


1.1. From a Single Column

We will remove duplicates from a column using the Remove Duplicates command. As you can see in the image below, we have a list of Employee Names. First, we will find duplicates and remove them with the Remove Duplicates command.

highlighting duplicates with the Conditional Formatting tool.

  • Then, select the range B6:B19 and click as follows: Data => Data Tools => Remove Duplicates.

Getting the Remove Duplicates command from the Data tab in Excel.

  • The Remove Duplicates dialog box will appear. Then, check Employee Name => OK.

Checking Employee Name from the Remove Duplicates dialog box.

  • A pop-up dialog box will be visible saying 5 duplicate values found and removed. Then hit the OK

pop-up dialog box will be visible saying 5 duplicate values found and removed.

  • Therefore, we obtain all unique values removing duplicates from a list.

the final output after removing duplicates from a single column.


Keyboard Shortcut to Remove Duplicates

You can also use the keyboard shortcut to remove duplicates in Excel.

  • Press the Alt + A + M keys sequentially and you will get the Remove Duplicates dialog box.
  • Then, check Employee Name => OK.
  • Finally, you will obtain a list of unique values.

keyboard shortcut to remove duplicates in Excel


1.2. Across Multiple Columns

Now we will show you how to remove duplicates based on two or multiple columns using Excel’s Remove Duplicates command. First, we will highlight duplicate rows with the Conditional Formatting tool. As you can see from the below image, the 6th, 9th, 10th,12th, 18th, and 19th rows are duplicates. We will remove these duplicate rows based on Employee ID and Employee Name with the Remove Duplicates command.

highlighting duplicate rows with Conditional Formatting

  • Next, select the range B6:E19 and go to Data => Data Tools => Remove Duplicates.
  • Thus, The Remove Duplicates dialog box will appear. Then, Check Employee ID and Employee Name => OK.

Getting the Remove Duplicates command from the Data tab in Excel.

  • Therefore, we’ll get unique rows removing duplicate rows.

the final output after removing duplicates from multiple columns.


2. Removing Duplicate Rows From Excel Table

Now you will learn to remove duplicate rows from Excel Table using the Remove Duplicates command. The Remove Duplicates command is also visible in the Table Design tab when you select the table. Likewise, we have a dataset in a table format and we will erase duplicates by applying the Remove Duplicate tool here.

Sample dataset for removing duplicates from an Excel table

  • First, select the table and click sequentially: Table Design => Remove Duplicates.
  • Thus, The Remove Duplicates dialog box will appear.
  • Then, We will remove these duplicate rows based on the Employee ID and Employee Name column which means if these two parameters are similar then the rows will be considered duplicates. So, check Employee ID and Employee Name => OK.

Getting the Remove Duplicates command from the Table Design tab in Excel.

  • As a result, all the duplicate rows will be removed from the table.
  • The Employee ID containing A124 & Employee Name with Morris King has been removed from the 2nd instance.

The final output after removing duplicates from the Excel table.


3. Removing Duplicate Rows Based on Multiple Excel Columns

In this section, we will remove duplicate rows based on two or multiple columns using the Excel Advanced Filter tool.  The Advanced Filter tool in Excel is used to find data that meets multiple complex criteria.

  • Initially, select the B6:E19 range and click as follows: Data => Sort & Filter => Advanced.
  • Then, an Advanced Filter dialog box will appear.
  • Next, select Copy to another location from the Action field.
  • Further, Select List range $B$5:$E$19, and output location $B$23.
  • Also, check the Unique records only option => OK.

Getting the Advanced Filter command from Data tab in Excel.

  • Therefore, all the filtered unique data will show in the B23:E33 range.

The final output after removing duplicates with Advanced Filter tool.


4. Applying Excel UNIQUE Function to Remove Duplication

By applying the UNIQUE function, you can simply get unique values and remove duplicates in Excel. The UNIQUE function keeps only 1st instance and ignores the rest of a dataset. It returns with an array format.

  • Insert the following UNIQUE formula in the B6 cell.
=UNIQUE(B6:B19)
  • And you will get the unique names in an array format.

Using the UNIQUE function to remove duplicates in Excel

Note: The UNIQUE function returns with an array format. Therefore, If any pre-defined value exists in the array range, it will return #SPILL! error.

5. Removing Duplicates in Excel But Keeping 1st Instance Only

You can keep the 1st instance only and remove duplicates by using the IF-COUNTIF together in an Excel formula. The COUNTIF function counts the number of instances and the IF function returns the first value only ignoring 2nd or 3rd instances. Keep in mind that this formula doesn’t return array format, so you must use the Fill Handle tool for an entire column.

  • By applying the following IF-COUNTIF formula, we obtain the Morris King in the D6 cell.
=IF(COUNTIF($B$6:$B6, $B6)=1, B6, "")
  • Use the Fill Handle tool to copy the formula in the adjacent cells.

Using IF and COUNTIF functions to erase duplicates in Excel


6. Using Excel Formula and Filter Tool to Remove Duplicates

Now we will show you how to remove duplicates with Excel formula and Filter tool combined. To do so, first, we will find duplicate rows with the IF-COUNTIFS formula. Then we will use the Filter tool to display the duplicate rows only. Now, the Visible cells only option from the Go To Special dialog box will be used to remove duplicate rows.

  • By using the following IF-COUNTIFS formula in the F6 cell, we’ll obtain the output text Unique.
=IF(COUNTIFS($B$6:$B6, $B6, $C$6:$C6, $C6, $D$6:$D6, $D6,$E$6:$E6, $E6)>1, "Duplicate row", "Unique")
  • Drag down the Fill Handle tool to identify the unique and duplicate rows.

finding duplicate rows with the IF-COUNTIFS formula

  • Now, we will find out the duplicate rows only with the Filter tool.
  • To do so, select the B5:F5 range and click as follows: Data => Sort & Filter => Filter.

Using the Filter tool from the Data tab

  • Next, click on the Duplicate Row? dropdown => check Duplicate row => OK.

Checking duplicate row to show duplicates only

  • Now we need to select only duplicate rows.
  • So, select sequentially: Home => Editing => Find & Select => Go to Special.
  • Thus, a Go To Special dialog box shows up.
  • Select the Visible cells only option => OK.

Selecting the Visible cells only option from the Go To Special dialog box.

  • As a result, all the visible cells will be selected. Now our job is to delete them.
  • To delete duplicate rows from the Context menu list, Right-click on the Mouse => Delete Row => OK.

Deleting visible rows in Excel

  • Therefore, you will see no data in the spreadsheet.
  • Now click on the Filter drop-down => check Unique => OK.

Checking Unique values from Filter drop-down

  • Finally, all the unique rows will appear.

Thus all the unique values are obtained by removing duplicates in Excel.


7. Removing Duplicates Based on Criteria in Excel

With the Advanced Filter tool, you can remove duplicates based on criteria in Excel. Consider a situation when you are likely to import products from some vendors and there are some duplicate rows. Here we’ll find the duplicates based on 2 criteria- The vendor name will be Believe Farmers & the price will be over $15000.

Sample data for removing duplicates based on criteria in Excel

  • So, select the B6:F14 range and click as follows: Data => Sort & Filter => Advanced.
  • Then, an Advanced Filter dialog box will appear.
  • Next, select Copy to another location from the Action field.
  • After that, Select List range $B$5:$E$19, criteria range $E$16:$F$17, and output location $B$19.
  • Also, check the Unique records only option => OK.

Selecting Advanced Filter tool to apply criteria

  • As a result, all unique rows containing Believe Farmers and prices over $15000 will be brought out.

Removing duplicates with Advanced Filter.


8. Apply VBA Macro to Remove Duplicates in Excel

Now we will make a VBA Macro that is applicable anywhere in the worksheet. For a large dataset, it is very useful and saves time. However, you can develop VBA code to apply multiple datasets, worksheets, or workbooks at the same time. It will remove duplicates automatically.

Sub Remove_Duplicates_in_Excel()
Dim inp As Range
Set inp = Application.InputBox("Select input range:", Type:=8)
If WorksheetFunction.CountA(inp) > 0 Then
    inp.RemoveDuplicates Columns:=Array(1), Header:=xlNo
Else
    MsgBox "No Data Selected."
End If
End Sub

Saving the VBA Macro to remove duplicates in Excel

  • Now select as follows sequentially: Developer => Macros => Remove_Duplicates_in_Excel => Run.
  • Select the input range and get the output after removing duplicates.

Removing duplicates with VBA Macro


9. Using Excel Power Query Tool to Remove Duplicates

You can also use the Power Query tool to remove duplicates in Excel. Power Query allows to import data from any external or internal sources. But in this approach, you need to perform several steps. Please follow the steps carefully.

  • First, select B5:E19 range and click sequentially, Data => From Table/Range.

Opening table with Power Query Editor

  • Then it will open with a Power Query Editor.
  • Next, we will find duplicates based on Employee ID. So, Right-Click on the 1st column and select the Remove Duplicates command.

Selecting Remove Duplicates from Power Query editor

  • Thus, by removing duplicates, all the unique values will show.
  • After that, select Home => Close & Load drop-down => Close & Load To.

Loading data to Excel worksheet

  • Thus, the Import Data dialog box will appear.
  • Since, we are likely to import data into a table format in the existing worksheet, select Table => Existing worksheet => $B$24 => OK.

Import Data dialog box to import data into a table format in the existing worksheet

  • Therefore, all the unique rows will be inserted into the worksheet erasing the duplicate rows.

Obtaining unique rows removing duplicates in Excel with Power Query.


How to Undo Remove Duplicates in Excel?

Suppose, we removed the duplicates. But it is no longer needed. So, we need to undo the remove duplicates operation in Excel.

  • Just simply click the Undo command from the Quick Access Tool.

Selecting Undo command.

Alternative: You can also press Ctrl + Z keys to undo the operation.
  • Therefore, all the data including duplicates will be shown.

The main dataset after undoing the operation


How to Hide Duplicate Values Instead of Removing Them in Excel?

Previously, we learned to remove duplicates. But in this section, we will learn to hide duplicate values instead of removing them in Excel with the Filter tool.

  • First, we must figure out unique and duplicate rows using the IF-COUNTIFS formula like method-6.
=IF(COUNTIFS($B$6:$B6, $B6,$C$6:$C6, $C6, $D$6:$D6, $D6, $E$6:$E6, $E6)>1, "Duplicate row", "Unique")

figuring out unique and duplicate rows using Excel IF-COUNTIFS formula

  • Select the B5:F5 range and select as follows: Data => Sort & Filter => Filter.
  • Just click on the Filter drop-down => Check Unique => OK.
  • Checking Unique to hide duplicatesAs a result, unique values will show hiding duplicates.

Displaying the Unique values only


What Can be Possible Reasons If You Can’t Remove Duplicates in Excel Properly?

Remove Duplicates tool does not work for two lists. Rather, it treats the cells as duplicate rows. Look at the following image, there are 2 lists of Sales Region.

Issue:

When we select the range B6:D14 and apply the Remove Duplicates command, it says No duplicate values found with a pop-up message. But the region of Ohio is clearly present in both lists. So, the Remove Duplicate tool is not sufficient to find all duplicate values properly here, right?

Selecting data and applying the Remove Duplicates command

Solution:

  • So, we will make a list in the F column copying data from Sales Regions 1 and 2.

Making a list by copying from two separate lists

  • Now, select the F6:F23 range.
  • Then, press the Alt + A + M keys to apply the Remove Duplicates command.

Applying keyboard shortcut to remove duplicates in Excel

  • Thus, the Remove Duplicates dialog box shows up.
  • Next, check Sales Regions => OK.

Checking Sales Regions option from Remove Duplicates dialog box.

  • As a result, we obtain every Sales Region only once.

Sales regions without duplications


Download Practice Workbook

Download the free workbook for details and practice yourself.


Conclusion

Throughout the article, we explained several tips and tricks to remove duplicates in Excel. You can use the Remove Duplicates command to erase duplicate values from single and multiple columns. Also, you can remove duplicate rows from a Table with the Remove Duplicates command from the Table Design tab. Application of the Advanced filter is also useful for removing duplicates. It also applicable with multiple criteria. The UNIQUE function extracts unique values whereas, the IF-COUNTIF formula finds out the first instances leaving multiple instances blank. On the other hand, you can apply the Excel formula and Filter tool to remove duplicates. Power Query is useful for removing duplications by importing data from any external or internal sources. Finally, the application of VBA Macro facilitates you to remove duplicates from any selection.

Remove Duplicates in Excel: Knowledge Hub

<< Go Back to Duplicates in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
MD Tanvir Rahman
MD Tanvir Rahman

MD Tanvir Rahman, BUET graduate in Naval Architecture and Marine Engineering, dedicated over a year to the ExcelDemy project. He is an Excel and VBA Content Developer. Having authored 50+ insightful articles, he actively updates and improves over 80 articles, reflecting his commitment to accuracy and currency, managing day-to-day operations, and analyzing and developing Excel and VBA tutorials. His broad interests encompass Data Analysis, Advanced Excel, VBA Macro, Excel Templates, Excel Automation, and Excel Power Query, showcasing a... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo