How to find, highlight and remove duplicates in Excel

To remove duplicates in Excel, select the data, then on the Data tab choose Remove Duplicates. Tick the columns that must match for two rows to count as duplicates and click OK: Excel keeps the first row of each set and deletes the rest. To find duplicates without deleting anything, select the cells and choose Home, Conditional Formatting, Highlight Cells Rules, Duplicate Values.

This guide shows how to find duplicates in Excel before you change anything: highlight them, count them and mark the repeats. Then it covers removing them, with Remove Duplicates or the UNIQUE function, counting unique values, comparing two lists and the duplicates Excel misses. After that come 10 exercises to practise them.

Every result on this page comes from the practice sheet our lessons use. We ran the formulas through it and printed what they returned.

How to find duplicates in Excel

This sign-up sheet for a workshop has ten rows but fewer people. Asha and Chen sent the form twice, Ben signed up for two sessions, and two different people called Sam signed up once each.

Sign-ups for a workshop, with a name, an email and a session on each row
ABC
1NameEmailSession
2Ashaasha@example.comMorning
3Benben@example.comAfternoon
4Chenchen@example.comMorning
5Ashaasha@example.comMorning
6Devdev@example.comEvening
7Benben@example.comEvening
8Samsam.k@example.comAfternoon
9Chenchen@example.comMorning
10Samsam.r@example.comMorning
11Ellaella@example.comAfternoon

Highlight duplicates

  1. Select the cells to check: the emails in B2:B11 here.
  2. On the Home tab, choose Conditional Formatting, then Highlight Cells Rules, then Duplicate Values.
  3. Leave the first box on Duplicate, pick a format and click OK.

Excel colours every copy, the first one included: 6 cells here, two each for Asha, Ben and Chen. Choose Unique in the first box to colour the values that appear only once instead. The rule stays on the cells, so a duplicate typed into them later is coloured too.

Check the column that holds something different for each person: the email here. Select the names in A2:A11 instead and both Sams are coloured as well, though they’re two people with two emails.

To see only the coloured rows, turn on the filter from the Data tab, click the arrow on the Email heading and choose Filter by Color. To take the colours off, choose Conditional Formatting, then Clear Rules. Excel can’t highlight duplicates in the Values area of a PivotTable.

Count how many times each value appears

COUNTIF counts the cells in a range that match a value. Give it the whole column and the cell on the same row, and it says how many times that row’s value appears. Anything above 1 is a duplicate.

FormulaWhat it doesResult
=COUNTIF($B$2:$B$11,B2)How many times the email in B2 appears in the list.2
=COUNTIF($B$2:$B$11,B6)The same formula on row 6: Dev’s email appears once.1
=IF(COUNTIF($B$2:$B$11,B2)>1,"Duplicate","")A label in place of the count, left blank for an email that appears once.Duplicate

Put the first formula in D2 and fill it down. The $ signs keep the range in place while B2 moves down a row at a time. Then sort or filter column D to bring the duplicates together.

Try COUNTIF in your browser. This task comes from lesson 24 of Excel Foundations, our free course, and it checks your formula the way the course does.

In B10, count how many expenses are Travel.

Example data for this task
ABCD
1ItemCategoryAmountPaid
2Taxi to airportTravel42.50Yes
3Team lunchMeals86.00No
4Hotel, 2 nightsTravel310.00Yes
5Printer inkOffice38.90Yes
6Client dinnerMeals124.00Yes
7Train ticketTravel27.00No
8NotebooksOffice15.60No
9
10Travel expenses (your answer goes here)
11Over 100
12Unpaid

Create a free account to carry on with the rest of Excel Foundations.

Mark the repeats, not the first copy

Remove Duplicates keeps the first copy of each value and deletes the rest. To mark only the rows it would delete, lock the start of the range but not its end: =COUNTIF($B$2:$B2,B2)>1. As you fill it down, the range grows with it, so each row counts the copies from the top down to itself.

FormulaWhat it doesResult
=COUNTIF($B$2:$B2,B2)>1Row 2, Asha’s first sign-up: there’s no copy above it.FALSE
=COUNTIF($B$2:$B5,B5)>1Row 5, after filling down: her second, so it’s a repeat.TRUE

Filter that column for TRUE to see the rows that would go, and check them before anything is deleted.

Find duplicate rows

A row is a duplicate only when every column that matters matches. COUNTIFS checks several columns at once: give it each column and the cell from the same row.

FormulaWhat it doesResult
=COUNTIFS($A$2:$A$11,A2,$B$2:$B$11,B2,$C$2:$C$11,C2)Asha’s morning sign-up: two rows match on every column.2
=COUNTIFS($A$2:$A$11,A3,$B$2:$B$11,B3,$C$2:$C$11,C3)Ben’s afternoon sign-up: his other one is for the evening.1

To colour the repeated rows, select A2:C11 and choose Conditional Formatting, then New Rule, then Use a formula to determine which cells to format. Enter the rule for the first row and choose a format. Each email belongs to one person, so the email and the session are enough to compare here.

FormulaWhat it doesResult
=COUNTIFS($B$2:$B2,$B2,$C$2:$C2,$C2)>1The rule as you enter it, for row 2: a first copy, so no format.FALSE
=COUNTIFS($B$2:$B5,$B5,$C$2:$C5,$C5)>1The same rule on row 5: a repeat, so the row is coloured.TRUE

The $ before each column letter keeps every cell in a row checking the same columns, so the whole row takes the format. Try COUNTIFS on two conditions: this task comes from lesson 27 of Excel Foundations.

In B10, count the unpaid Travel expenses.

Example data for this task
ABCD
1ItemCategoryAmountPaid
2Taxi to airportTravel42.50Yes
3Team lunchMeals86.00No
4Hotel, 2 nightsTravel310.00Yes
5Printer inkOffice38.90Yes
6Client dinnerMeals124.00Yes
7Train ticketTravel27.00No
8NotebooksOffice15.60No
9
10Unpaid travel (your answer goes here)
11Paid travel total
12Paid over 100

Create a free account to practise the rest of Excel Foundations.

How to remove duplicates in Excel

Excel has four ways to remove duplicates, and only one of them deletes rows from the data itself.

WayWhat it doesWhen to use it
Remove DuplicatesDeletes the repeated rows and keeps the first of each set.A one-off clean-up, on a copy of the data.
Advanced FilterCopies each different row to another place, or hides the repeats.Keeping the original as it is, in any desktop version of Excel.
UNIQUELists each value or row once, and changes when the data does.A list that stays up to date, in Excel 2021 and later, Microsoft 365 and the web.
Power QueryTakes them out each time the query is refreshed.Data you import again and again.

Remove Duplicates is the quickest:

  1. Select the data, headings included: A1:C11 here. In a table, a cell in it is enough.
  2. On the Data tab, choose Remove Duplicates, in the Data Tools group. On Windows, pressing Alt, then A, then M opens it from the keyboard.
  3. Tick the columns that have to match. Leave My data has headers ticked when the first row holds headings.
  4. Click OK. Excel says how many duplicate values it found and removed, and how many unique values remain.

Excel keeps the first row of each set and deletes the others: the whole row, columns you didn’t tick included. Nothing outside the selection moves. The rows are deleted, not hidden, so Microsoft suggests copying the data to another sheet first, and Ctrl+Z undoes it straight away. Excel for the web has Remove Duplicates on its Data tab too.

Choose the columns that make a duplicate

The columns you tick decide what counts as a duplicate, and on the sign-up sheet three choices leave three different lists. Each formula below counts the rows Remove Duplicates would leave, before anything is deleted.

FormulaWhat it doesResult
=ROWS(UNIQUE(A2:C11))Every column ticked: only the forms sent twice go.8
=ROWS(UNIQUE(B2:B11))Email ticked: one row for each email.7
=ROWS(UNIQUE(A2:A11))Name ticked: one row for each name.6

With every column ticked, only Asha’s and Chen’s second forms go. With Email alone, Ben’s evening sign-up goes as well, which is right only if each person may come once. With Name alone, the second Sam goes too, though that Sam is someone else. Tick the columns that identify what you want one row for: a person, a booking or an order.

Remove duplicates from one column

Select one column of a table and choose Remove Duplicates, and Excel warns that there’s data next to it, offering to expand the selection or carry on with the current one. Expand it unless the column stands on its own. Carrying on deletes cells from that column only, and the cells below move up, so the rest of each row no longer lines up with them.

To clean one list on its own, such as a column of names, copy it to an empty sheet first, then remove the duplicates there. Or leave the data as it is and list each name once with UNIQUE, as the next section shows.

Choose which copy to keep

Remove Duplicates always keeps the first copy, counting from the top. To keep a different one, sort the data first so that copy comes first. For the newest of each, sort by date, newest to oldest, then remove the duplicates.

Copy each row once and keep the original

  1. Select the data, headings included.
  2. On the Data tab, in the Sort & Filter group, choose Advanced.
  3. Choose Copy to another location and type a cell in the Copy to box, such as E1.
  4. Tick Unique records only and click OK.

Excel copies each different row once, headings and all, and leaves the original as it was. A row counts as a repeat only when every column matches. Choose Filter the list, in-place instead to hide the repeated rows, then Clear on the Data tab to show them again.

Power Query, which opens from the Data tab with From Table/Range, can take duplicates out of data you import each time it’s refreshed: select the columns, then on its Home tab choose Remove Rows, then Remove Duplicates. Unlike the rest of Excel, it treats capital and small letters as different, and Microsoft doesn’t promise that it keeps the first copy.

Remove duplicates with a formula: UNIQUE

In Excel 2021 and later, Microsoft 365 and Excel for the web, UNIQUE lists each value once and leaves the data as it is. Type it in an empty cell and the results spill into the cells below. Those cells must be empty: if they aren’t, UNIQUE shows a #SPILL! error.

FormulaWhat it doesResult
=UNIQUE(A2:A11)Each name once, in the order they first appear.Asha, Ben, Chen, Dev, Sam and Ella
=SORT(UNIQUE(A2:A11))The same names, from A to Z.Asha, Ben, Chen, Dev, Ella and Sam
=UNIQUE(A2:A11,,TRUE)Only the names that appear once.Dev and Ella

The list keeps up with the data: change a name in column A and it changes too. TRUE as the third argument keeps only the values that appear exactly once, so Asha, Ben, Chen and Sam all drop out. Like Remove Duplicates, UNIQUE ignores case.

Give UNIQUE more than one column and it returns each different row: =UNIQUE(A2:C11) returns the 8 rows Remove Duplicates keeps with every column ticked. To swap the original for the list, copy the results and paste them with Paste Special, Values, so they stay put when the formula goes.

Excel 2019 and earlier don’t have UNIQUE. There, use Remove Duplicates or Advanced Filter, or mark the repeats with COUNTIF as above.

Count duplicates and unique values

UNIQUE and COUNTA together answer the counting questions: how many different values there are, how many repeats Remove Duplicates would take out, and how many cells Duplicate Values would colour.

FormulaWhat it doesResult
=COUNTA(UNIQUE(B2:B11))How many different emails: one for each person.7
=COUNTA(B2:B11)-COUNTA(UNIQUE(B2:B11))How many repeats: the rows Remove Duplicates takes out with Email ticked.3
=COUNTA(B2:B11)-COUNTA(UNIQUE(B2:B11,,TRUE))How many cells have a copy: the cells Duplicate Values colours.6
=COUNTA(UNIQUE(B2:B11,,TRUE))How many emails appear only once.4

So 7 people signed up, though the sheet has 10 rows. Leave empty cells out of the range: UNIQUE returns an empty cell as 0, which COUNTA counts as one more value. In Excel 2019 and earlier, =SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11)) counts the different values instead, as long as the range has no empty cells.

Compare two lists for duplicates

To find the values two lists share, check each value in one list against the other. This club has its members for this year in column A and last year’s in column C.

A club’s members this year, in column A, and last year, in column C
ABC
1This yearLast year
2InesLeo
3JonasQuinn
4KemiJonas
5LeoPia
6MayaTheo
7NicoNico
8Rosa
9Pia
FormulaWhat it doesResult
=COUNTIF($C$2:$C$7,A2)>0Ines isn’t on last year’s list.FALSE
=COUNTIF($C$2:$C$7,A3)>0Jonas is.TRUE
=IF(COUNTIF($C$2:$C$7,A2),"Renewed","New")A word in place of TRUE or FALSE, for Ines.New
=ISNUMBER(MATCH(A3,$C$2:$C$7,0))MATCH finds Jonas on the list, and ISNUMBER turns his place into TRUE.TRUE
=IFNA(VLOOKUP(A2,$C$2:$C$7,1,FALSE),"Not found")VLOOKUP returns the name when it finds it, and IFNA a message when it doesn’t.Not found

Fill any of them down column B to check every member. COUNTIF counts the name on last year’s list, so 0 means it isn’t there, and the >0 turns the count into TRUE or FALSE. MATCH and VLOOKUP do the same job. On their own they return #N/A when the name isn’t on the list, which is why ISNUMBER and IFNA wrap them here.

To colour the names on both lists, select A2:A9, hold Ctrl and select C2:C7, then choose Duplicate Values. Excel treats the two ranges as one, so Jonas, Leo, Nico and Pia are coloured in both lists. It would also colour a name repeated within one list. To colour only this year’s returning members, select A2:A9 and use a formula rule instead: =COUNTIF($C$2:$C$7,$A2)>0.

When Excel misses duplicates

  • Extra spaces. Asha, and Asha with a space after it, look the same, but Excel treats them as different values. TRIM takes the spaces out: put =TRIM(A2) in a spare column, fill it down, then copy the results and paste them over the original with Paste Special, Values.
  • Different formats. Remove Duplicates and Advanced Filter compare what the cells show, not what they hold, so the same date shown as 08/12/2026 in one cell and 8 Dec 2026 in another counts as two values. Give the column one format before you remove duplicates.
  • Capital and small letters. Remove Duplicates, UNIQUE, COUNTIF and Duplicate Values all ignore case, so asha@example.com and Asha@example.com count as duplicates. When case matters, compare with EXACT, which doesn’t ignore it.
  • Long ID numbers. Duplicate Values reads text that looks like a number as a number, and Excel keeps only 15 digits of a number, so two long IDs that differ after the fifteenth digit can be coloured as duplicates. Check a pair with =EXACT(A2,A3), which compares the text itself.
  • Remove Duplicates won’t run. It doesn’t work on data with an outline or subtotals. Take them off first: on the Data tab, choose Subtotal, then Remove All.
  • The counts are too high. Select only the rows with data. Empty rows inside the selection match each other, so Excel counts them among the duplicates it removes.

On the sign-up sheet, A2 holds Asha, with a capital A:

FormulaWhat it doesResult
=A2="asha"An equals sign ignores case, as COUNTIF does.TRUE
=EXACT(A2,"asha")EXACT doesn’t.FALSE

Extra spaces often come in with data copied from a website or another system. Try TRIM here: this task comes from lesson 22 of Excel Foundations.

In B2:B6, clean each imported name with TRIM.

Write the formula for B2. We’ll fill it down to B6 for you.

Example data for this task
ABC
1Name as importedCleanedLength
2 Ola Mensah (your answer goes here)
3Priya Nair (your answer goes here)
4Tom Becker (your answer goes here)
5 Lerato Dube (your answer goes here)
6Marco Rossi (your answer goes here)

Create a free account to practise the rest of Excel Foundations.

Duplicate exercises with answers

These 10 exercises run on two tables. Some need a formula, and the rest use Excel’s menus, where the answers say what you should see. Download the workbook to do them in Excel, or type the tables in yourself, starting in cell A1.

Download the practice workbook

Excel file, 10 KB. It opens in Google Sheets too.

Exercises 1 to 7: an order log

Ten rows from a shop’s order log. Two orders were entered twice by mistake, and some customers ordered more than once, which is fine. The yellow cells show where each formula goes. The other exercises use Excel’s menus.

The table for exercises 1 to 7
ABCDEFG
1OrderCustomerAmountCountRepeatDifferent orders
22051Kai120 (your answer goes here) (your answer goes here) (your answer goes here)
32052Lena85 (your answer goes here) (your answer goes here)
42053Malik240 (your answer goes here) (your answer goes here)Customers
52052Lena85 (your answer goes here) (your answer goes here) (your answer goes here)
62054Nora60 (your answer goes here) (your answer goes here)
72055Kai150 (your answer goes here) (your answer goes here)
82056Oscar95 (your answer goes here) (your answer goes here)
92053Malik240 (your answer goes here) (your answer goes here)
102057Priya310 (your answer goes here) (your answer goes here)
112058Lena70 (your answer goes here) (your answer goes here)
  1. In D2, count how many times the order number in A2 appears in A2:A11. Fill it down to D11.
  2. Select A2:A11 and highlight the duplicates: on the Home tab, choose Conditional Formatting, then Highlight Cells Rules, then Duplicate Values. How many cells change colour, and which orders are they?
  3. In E2, show TRUE if the order number in A2 has already appeared above it, and FALSE if it hasn’t. Fill it down to E11.
  4. In G2, count the different order numbers.
  5. Copy A1:C11 to a new sheet and select it. On the Data tab, choose Remove Duplicates and tick only Order. How many rows does Excel remove, and how many are left?
  6. In G5, list each customer once.
  7. Undo, then remove the duplicates again with only Customer ticked. How many rows are left, and what goes wrong?

Answers to exercises 1 to 7

ExerciseFormulaHow it worksResult
1=COUNTIF($A$2:$A$11,A2)The $ signs keep the range in place while A2 moves down. A count of 2 or more is a duplicate.1, 2, 2, 2, 1, 1, 1, 2, 1, 1
2Home tab: Conditional Formatting, Highlight Cells Rules, Duplicate ValuesEvery copy is coloured, the first one included: the cells with a count above 1 in column D.4 cells: both copies of orders 2052 and 2053.
3=COUNTIF($A$2:$A2,A2)>1Only the start of the range is locked, so the range grows as the formula fills: E5 counts A2:A5. TRUE marks the rows Remove Duplicates deletes.FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE
4=COUNTA(UNIQUE(A2:A11))UNIQUE lists each order number once and COUNTA counts the list: 8 orders in 10 rows. Counting the first copies, the FALSE values in column E, works in every version. Also works: =COUNTIF(E2:E11,FALSE).8
5Data tab: Remove Duplicates, with only Order tickedExcel keeps the first copy of each order and deletes the rows below it: the rows marked TRUE in column E.2 removed and 8 left, one for each order.
6=UNIQUE(B2:B11)UNIQUE keeps each name the first time it appears, in that order. Lena placed three orders and is listed once.Kai, Lena, Malik, Nora, Oscar, Priya
7Data tab: Remove Duplicates, with only Customer tickedA customer can place more than one order, so a repeated name isn’t a duplicate. Tick the column that’s different on every real row: here, the order number.6 rows are left, one for each customer. 4 rows go, and 2 of them were real orders, such as Kai’s second.

Exercises 8 to 10: a guest list and the replies

Eight guests invited to an event, in column A, and the replies so far, in column D, in the order they came in. Column B shows who has replied, and the guests still to reply go in F2. The yellow cells show where each formula goes.

The table for exercises 8 to 10
ABCDEF
1InvitedRepliedRepliesNo reply yet
2Aiko (your answer goes here)Bram (your answer goes here)
3Bram (your answer goes here)Esme
4Cass (your answer goes here)Aiko
5Dimi (your answer goes here)Hal
6Esme (your answer goes here)Finn
7Finn (your answer goes here)
8Gia (your answer goes here)
9Hal (your answer goes here)
  1. In B2, show TRUE if the guest in A2 is on the list of replies in D2:D6, and FALSE if not. Fill it down to B9.
  2. In F2, list the guests who haven’t replied yet.
  3. Select A2:A9, hold Ctrl and select D2:D6, then choose Duplicate Values. How many cells change colour?

Answers to exercises 8 to 10

ExerciseFormulaHow it worksResult
8=COUNTIF($D$2:$D$6,A2)>0COUNTIF counts the guest’s name in the replies, 1 or 0 here, and >0 turns the count into TRUE or FALSE. Lock the replies with $ so they stay put as you fill. Also works: =ISNUMBER(MATCH(A2,$D$2:$D$6,0)).TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE
9=FILTER(A2:A9,B2:B9=FALSE)FILTER keeps the guests whose row in column B is FALSE. In Excel 2019 and earlier, turn on the filter from the Data tab and show the FALSE rows instead. Also works: =FILTER(A2:A9,NOT(B2:B9)).Cass, Dimi, Gia
10Home tab: Conditional Formatting, Highlight Cells Rules, Duplicate Values, with both ranges selectedWith both ranges selected, a name that appears twice anywhere in them counts as a duplicate. Neither list repeats a name, so the colours mark the names on both.10 cells: the 5 guests who replied, once in each list.

Questions

How do I find duplicates in Excel without deleting them?

Highlight them: select the cells, then on the Home tab choose Conditional Formatting, Highlight Cells Rules, Duplicate Values. Or count them with a formula beside the data, such as =COUNTIF($B$2:$B$11,B2) filled down: a count above 1 is a duplicate. Neither changes the data.

What formula removes duplicates in Excel?

UNIQUE, in Excel 2021 and later, Microsoft 365 and Excel for the web. =UNIQUE(A2:A11) lists each name on the sign-up sheet above once, Asha, Ben, Chen, Dev, Sam and Ella, and leaves the original as it is. No formula can delete cells, so to replace the original, copy the list and paste it as values, or use Remove Duplicates on the Data tab.

How do I count unique values in Excel?

=COUNTA(UNIQUE(B2:B11)) counts each different value once: 7 emails on the sign-up sheet. To count only the values that appear once, add TRUE as UNIQUE’s third argument: =COUNTA(UNIQUE(B2:B11,,TRUE)) gives 4. Excel 2019 and earlier don’t have UNIQUE, and there =SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11)) counts the different values.

How do I find duplicates in two columns?

Check each value in one column against the other: =COUNTIF($C$2:$C$7,A2)>0, filled down, shows TRUE for every value in column A that’s also in C2:C7. To colour them instead, select both ranges, holding Ctrl for the second, and choose Duplicate Values.

How do I highlight duplicate rows in Excel?

Select the rows, choose Conditional Formatting, then New Rule, then Use a formula to determine which cells to format, and give COUNTIFS each column that has to match, such as =COUNTIFS($B$2:$B$11,$B2,$C$2:$C$11,$C2)>1 for columns B and C. The $ before each column letter makes the whole row take the format.

Can VLOOKUP find duplicates?

Not on its own: VLOOKUP and XLOOKUP return the first match and ignore any others. They can tell you whether a value is on another list, as =IFNA(VLOOKUP(A2,$C$2:$C$7,1,FALSE),"Not found") does. To count the copies of a value, use COUNTIF, and to return every match, FILTER. Our comparison of XLOOKUP and VLOOKUP covers both lookups.

How do I remove duplicates in Google Sheets?

Select the data, then choose Data, Data cleanup, Remove duplicates, tick the columns to compare and click Remove duplicates. Google Sheets treats cells with the same value but different case, formatting or formulas as duplicates. COUNTIF, COUNTIFS and UNIQUE work there too.

Keep practising

Excel Foundations, our free course, covers COUNTIF and COUNTIFS in its seventh module and TRIM in its sixth: the formulas behind most duplicate checks. It has 30 short lessons and 82 exercises in a live sheet, and passing its test earns a certificate of completion.

See what’s in Excel Foundations

UNIQUE, SORT and FILTER have a module of their own in Excel Intermediate, and so does cleaning messy data: TRIM, SUBSTITUTE and numbers stored as text. Excel Test Prep practises the tools that employers’ Excel tests ask about. Both come with Pro. For more practice, try our Excel exercises with answers, or our guide to drop-down lists, which builds a list with UNIQUE.

Start with Excel Foundations. It’s free.

Pro is $19 a month or $99 a year for every other track, with SQL included as it launches.

Create free account Go to your lessons