Written by Allen Wyatt (last updated June 28, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365
Everybody runs into the need at one time or another—to delete duplicate entries from a list of text entries. Suppose you have the text values in column A of a worksheet, and they run for about 500 rows. If you want to delete any duplicates in the list, you may be looking for the easiest way to do it. There are actually multiple ways you can accomplish this task in Excel.
Using the Delete Duplicates Tool
Perhaps the simplest method is to select the data from which you want to delete duplicates and then display the Data tab of the ribbon. Click the Remove Duplicates tool, in the Data Tools group. Excel displays the Remove Duplicates dialog box.
The great thing about the Remove Duplicates dialog box is that it lists the names of each column in your data. (The tool assumes that you have heading labels in the first row of your data.) You can then make sure there is a check mark next to each column you want checked for duplicates. When you click the OK button, your data in analyzed and the duplicate rows removed. (Again, duplicates are determined based on the columns selected in the Remove Duplicates dialog box.)
Using Data Filtering
Another manual method is to use data filtering to determine the unique values. Make sure the column has a label at the top of it, then select a cell in the column. Display the Data tab of the ribbon and click Advanced in the Sort & Filter group. Use the controls in the resulting dialog box to specify that you want to copy the unique values to another location which you specify.
Using a Formula
You can also use a formula to manually determine the duplicates in the list. Sort the values in the column, and then enter the following formula in cell B2:
=IF(A2=A1,"Duplicate","")
Copy the formula down to all the cells in column B that have a corresponding value in column A. Select all the values in column B and press Ctrl+C. Use Paste Special to paste just the values into the same selected cells. You've now converted the formulas into their results. Sort the two columns according to the contents of column B, and all of your duplicate rows will be in one area. Delete these rows, and you have your finished list of unique values.
Using a Macro
The manual approaches are fast and easy, but if you routinely have to delete duplicate values from a column, a macro may be more your style. The following macro relies on data filtering, much like the earlier manual method:
Sub CreateUniqueList() Dim rData As Range Dim rTemp As Range Set rData = Range(Range("a1"), Range("A1048576").End(xlUp)) rData.EntireColumn.Insert Set rTemp = rData.Offset(0, -1) rData.AdvancedFilter _ Action:=xlFilterCopy, _ CopyToRange:=rTemp, _ Unique:=True rTemp.EntireColumn.Copy _ rData.EntireColumn Application.CutCopyMode = False rTemp.EntireColumn.Delete Set rData = Nothing Set rTemp = Nothing End Sub
The macro creates a temporary column, uses advanced filtering to copy the unique values to that column, then deletes the original data column. The result is just unique values in column A. If you don't want your macro to use the data filtering feature of Excel, then the following much shorter macro will do the trick:
Sub RemoveDups() Dim rData As Range Set rData = Range(Range("a1"), Range("A1048576").End(xlUp)) rData.RemoveDuplicates Columns:=Array(1), Header:=xlYes End Sub
The key in this macro is using the RemoveDuplicates method, which relies on an array that contains the column numbers you want to check for duplicates. The macro shown here operates only on the contents of column A, but you could easily modify it to work on data in more than a single column. All you would need to do is to change rData so that it represented the larger data area and then modify the columns parameter so that it pointed to the columns you want checked:
rData.RemoveDuplicates Columns:=Array(1,4), Header:=xlYes
Another macro-based approach is to develop your own code to check the values in the data set, in this manner:
Sub DelDups() Dim rngSrc As Range Dim NumRows As Integer Dim ThisRow As Integer Dim ThatRow As Integer Dim ThisCol As Integer Dim J As Integer, K As Integer Application.ScreenUpdating = False Set rngSrc = ActiveSheet.Range(ActiveWindow.Selection.Address) NumRows = rngSrc.Rows.Count ThisRow = rngSrc.Row ThatRow = ThisRow + NumRows - 1 ThisCol = rngSrc.Column 'Start wiping out duplicates For J = ThisRow To (ThatRow - 1) If Cells(J, ThisCol) > "" Then For K = (J + 1) To ThatRow If Cells(J, ThisCol) = Cells(K, ThisCol) Then Cells(K, ThisCol) = "" End If Next K End If Next J 'Remove cells that are empty For J = ThatRow To ThisRow Step -1 If Cells(J, ThisCol) = "" Then Cells(J, ThisCol).Delete xlShiftUp End If Next J Application.ScreenUpdating = True End Sub
The macro works on a selection you make before calling it. Thus, if you need to remove duplicate cells from the range A2:A974, simply select that range and then run the macro. When the macro is complete, the duplicate cells are removed, as are any blank cells.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12711) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Deleting Duplicate Text Values.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!
If you've got a list of names in a column, you may want to change the order of each name. For instance, the name have the ...
Discover MoreWhen working with data in Excel, you might want to figure out which rows of data represent duplicates of other rows. If ...
Discover MoreExcel includes the powerful INDIRECT function which can be used to assemble references to other cells in your workbook. ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-07-03 12:43:20
J. Woolley
The Tip's formula in column B
=IF(A2=A1, "Duplicate", "")
could be replaced by the following formula in cell B1
=TRANSPOSE(UniqueItems(A:A, TRUE))
which uses the UniqueItems function described in my comment here: https://excelribbon.tips.net/T010935
On the other hand, Tomek's formula
=UNIQUE(A:A)
includes a blank cell, which is displayed as zero (0), in its result. See my recent comment here: https://excelribbon.tips.net/T010105
The Tip's first two macros use the following obscure expression for the last non-blank cell in column A:
Range("A1048576").End(xlUp)
These expressions yield the same result but might be less obscure:
Range("A"&Rows.Count).End(xlUp)
Cells(Rows.Count, "A").End(xlUp)
All three expressions ignore hidden cells (if any).
This expression gives the last non-blank cell in column A including hidden cells:
Columns("A").Find(What:="*", After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, MatchCase:=False)
However, it is not necessary to determine the last non-blank cell in column A or worry about hidden cells. Here are alternative versions of the Tip's first two macros:
Sub CreateUniqueList2()
Columns("A").Insert xlShiftToRight, xlFormatFromRightOrBelow
With Columns("B") 'previously column A
.AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=.Offset(0, -1), Unique:=True
.Offset(0, -1).Copy .Offset(0, 0)
.Offset(0, -1).Delete
End With
End Sub
Sub RemoveDups2()
Columns("A").RemoveDuplicates Columns:=Array(1), Header:=xlYes
End Sub
Both macros assume row 1 is a header row. (Apparently this is automatic for the Range.AdvancedFilter method, but it is not well documented.)
Finally, here's an alternative version of the Tip's last macro:
Sub DelDups2()
Dim Uniq As Object, item As Variant
If Selection.Cells.Count = 1 Or Selection.Columns.Count > 1 Then Exit Sub
Intersect(Selection, Selection.Worksheet.UsedRange).Select
Set Uniq = CreateObject("Scripting.Dictionary")
For Each item In Selection.Value
If Not Uniq.Exists(item) Then Uniq.Add item, Null
Next item
If Uniq.Exists(Empty) Then Uniq.Remove Empty
Selection.ClearContents
Selection.Resize(Uniq.Count) = WorksheetFunction.Transpose(Uniq.Keys)
End Sub
This macro works on a selection you make before calling it, but that selection must have only one column.
Notice the Tip's macros and these alternatives replace any formula cells in the column with constant value results.
2025-06-29 00:03:23
Tomek
In the newest version of Excel, you can also use the UNIQUE function that will generate an array of unique names (it will spill down for as many cells as there are unique values. This function is available since 2021.
e.g. if your list is in Column A, =UNIQUE(A:A) in any other column will give you the list of unique values. Just make sure there is nothing below the cell where you enter the formula to interfere with the spill.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments