fxExcelReps

← Blog

How to Find Unique Values in Excel (6 Ways)

"How many different customers do we have?" "Give me the list of products we actually sold." Every report starts with a long column full of repeats, and the first job is to find the unique values in it.

There's no single best way. It depends on whether you need a list or a number, whether it has to update by itself, and which version of Excel you have. Here are the six methods I use, from the quickest click to the formula that does everything.

Every example below is a live sheet: click a cell to see its formula, or change the data and watch the results.

First: "unique" can mean two different things

Take this list: Anna, Boris, Anna, Clara.

  • Distinct values are all the different names, each once: Anna, Boris, Clara. This is what people usually mean by "remove the duplicates".
  • Unique values in the strict sense are the names that appear exactly once: Boris and Clara. Anna is out because she's in the list twice.

Most questions are about the first kind. The second answers questions like "which customers ordered only once?". The methods below show you how to get both.

1. COUNTIF with a growing range: mark the first appearance

This is my everyday method. It works in every version of Excel, it updates by itself, and it keeps the original order of the list.

The trick is a range whose start is locked and whose end moves:

=COUNTIF($B$2:B2, B2)

In row 2 it counts B2 inside $B$2:B2. Copied down, the range grows: $B$2:B3, $B$2:B4… So the formula counts how many times this name has appeared so far. The first time it's 1; every repeat is 2, 3, 4…

Turn it into a label and you've marked every first appearance:

=IF(COUNTIF($B$2:B2, B2)=1, "Yes", "")

Lock both ends of the range and COUNTIF counts the whole column instead. That gives you the second meaning of unique, the names that appear only once:

=IF(COUNTIF($B$2:$B$11, B2)=1, "Yes", "")
{"cells": {"A1": "Order", "B1": "Customer", "C1": "Seen so far", "D1": "First time?", "E1": "Total orders", "F1": "Only once?", "A2": "#1001", "B2": "Anna", "C2": "=COUNTIF($B$2:B2,B2)", "D2": "=IF(COUNTIF($B$2:B2,B2)=1,\"Yes\",\"\")", "E2": "=COUNTIF($B$2:$B$11,B2)", "F2": "=IF(COUNTIF($B$2:$B$11,B2)=1,\"Yes\",\"\")", "A3": "#1002", "B3": "Boris", "C3": "=COUNTIF($B$2:B3,B3)", "D3": "=IF(COUNTIF($B$2:B3,B3)=1,\"Yes\",\"\")", "E3": "=COUNTIF($B$2:$B$11,B3)", "F3": "=IF(COUNTIF($B$2:$B$11,B3)=1,\"Yes\",\"\")", "A4": "#1003", "B4": "Anna", "C4": "=COUNTIF($B$2:B4,B4)", "D4": "=IF(COUNTIF($B$2:B4,B4)=1,\"Yes\",\"\")", "E4": "=COUNTIF($B$2:$B$11,B4)", "F4": "=IF(COUNTIF($B$2:$B$11,B4)=1,\"Yes\",\"\")", "A5": "#1004", "B5": "Clara", "C5": "=COUNTIF($B$2:B5,B5)", "D5": "=IF(COUNTIF($B$2:B5,B5)=1,\"Yes\",\"\")", "E5": "=COUNTIF($B$2:$B$11,B5)", "F5": "=IF(COUNTIF($B$2:$B$11,B5)=1,\"Yes\",\"\")", "A6": "#1005", "B6": "David", "C6": "=COUNTIF($B$2:B6,B6)", "D6": "=IF(COUNTIF($B$2:B6,B6)=1,\"Yes\",\"\")", "E6": "=COUNTIF($B$2:$B$11,B6)", "F6": "=IF(COUNTIF($B$2:$B$11,B6)=1,\"Yes\",\"\")", "A7": "#1006", "B7": "Boris", "C7": "=COUNTIF($B$2:B7,B7)", "D7": "=IF(COUNTIF($B$2:B7,B7)=1,\"Yes\",\"\")", "E7": "=COUNTIF($B$2:$B$11,B7)", "F7": "=IF(COUNTIF($B$2:$B$11,B7)=1,\"Yes\",\"\")", "A8": "#1007", "B8": "Anna", "C8": "=COUNTIF($B$2:B8,B8)", "D8": "=IF(COUNTIF($B$2:B8,B8)=1,\"Yes\",\"\")", "E8": "=COUNTIF($B$2:$B$11,B8)", "F8": "=IF(COUNTIF($B$2:$B$11,B8)=1,\"Yes\",\"\")", "A9": "#1008", "B9": "Elena", "C9": "=COUNTIF($B$2:B9,B9)", "D9": "=IF(COUNTIF($B$2:B9,B9)=1,\"Yes\",\"\")", "E9": "=COUNTIF($B$2:$B$11,B9)", "F9": "=IF(COUNTIF($B$2:$B$11,B9)=1,\"Yes\",\"\")", "A10": "#1009", "B10": "Clara", "C10": "=COUNTIF($B$2:B10,B10)", "D10": "=IF(COUNTIF($B$2:B10,B10)=1,\"Yes\",\"\")", "E10": "=COUNTIF($B$2:$B$11,B10)", "F10": "=IF(COUNTIF($B$2:$B$11,B10)=1,\"Yes\",\"\")", "A11": "#1010", "B11": "Anna", "C11": "=COUNTIF($B$2:B11,B11)", "D11": "=IF(COUNTIF($B$2:B11,B11)=1,\"Yes\",\"\")", "E11": "=COUNTIF($B$2:$B$11,B11)", "F11": "=IF(COUNTIF($B$2:$B$11,B11)=1,\"Yes\",\"\")", "A13": "Different customers", "C13": "=COUNTIF(D2:D11,\"Yes\")", "A14": "Ordered only once", "C14": "=COUNTIF(F2:F11,\"Yes\")"}, "focus": "C3", "rows": 15, "note": "Click C3, C4, C5… and watch the range $B$2:B grow one row at a time. Change B11 to Elena."}

Five different customers (column D), and only two of them, David and Elena, ordered once (column F). Filter column D for "Yes" and you have your list of distinct customers.

2. Sorted column: compare each cell with the one above

If the list is sorted by the column you check, every repeat sits directly under the first one. Then you don't need COUNTIF at all, only a comparison with the cell above:

=B3=B2

TRUE means "same as the row above", so it's a repeat. FALSE means a new value starts here. For a readable label, flip it around with <> (not equal):

=IF(B2<>B1, "New", "")
{"cells": {"A1": "Order", "B1": "Customer", "C1": "Same as above?", "D1": "New name?", "A2": "#1001", "B2": "Anna", "C2": "=B2=B1", "D2": "=IF(B2<>B1,\"New\",\"\")", "A3": "#1003", "B3": "Anna", "C3": "=B3=B2", "D3": "=IF(B3<>B2,\"New\",\"\")", "A4": "#1007", "B4": "Anna", "C4": "=B4=B3", "D4": "=IF(B4<>B3,\"New\",\"\")", "A5": "#1010", "B5": "Anna", "C5": "=B5=B4", "D5": "=IF(B5<>B4,\"New\",\"\")", "A6": "#1002", "B6": "Boris", "C6": "=B6=B5", "D6": "=IF(B6<>B5,\"New\",\"\")", "A7": "#1006", "B7": "Boris", "C7": "=B7=B6", "D7": "=IF(B7<>B6,\"New\",\"\")", "A8": "#1004", "B8": "Clara", "C8": "=B8=B7", "D8": "=IF(B8<>B7,\"New\",\"\")", "A9": "#1009", "B9": "Clara", "C9": "=B9=B8", "D9": "=IF(B9<>B8,\"New\",\"\")", "A10": "#1005", "B10": "David", "C10": "=B10=B9", "D10": "=IF(B10<>B9,\"New\",\"\")", "A11": "#1008", "B11": "Elena", "C11": "=B11=B10", "D11": "=IF(B11<>B10,\"New\",\"\")", "A13": "Different customers", "D13": "=COUNTIF(D2:D11,\"New\")"}, "focus": "C3", "rows": 14, "note": "The list is sorted by customer, so every repeat sits right under its first appearance."}

It's the fastest method on big data, because each row looks at one cell only, not at the whole column. On a file with hundreds of thousands of rows, where a growing COUNTIF can take seconds to recalculate, this one stays instant.

Two things to watch:

  1. The data must be sorted by that column (Data → Sort). On an unsorted list this formula gives nonsense.
  2. Start the formula next to the first data row and compare it with the header (B2<>B1). The header is different from any name, so the first row is correctly marked "New".

3. Advanced Filter: copy the unique list somewhere else

No formulas at all, and it's been in Excel forever:

  1. Click any cell in the column (the header must be in the first row).
  2. Data → Advanced (in the Sort & Filter group). Keyboard: Alt A Q.
  3. Choose Copy to another location.
  4. List range: the column with its header, e.g. $B$1:$B$11.
  5. Copy to: an empty cell, e.g. $H$1.
  6. Tick Unique records only and press OK.

Excel copies every distinct value once, with the header on top. Your original data isn't touched.

The result is a static copy: if the data changes, run the filter again. You can also select several columns in the List range to get unique combinations, for example each customer and city pair once.

4. Remove Duplicates: the quickest click (but it deletes)

Data → Remove Duplicates, choose the column, OK. Excel deletes every repeat and tells you how many it removed and how many unique values remain.

It's fast, but it deletes rows from your data, and with several columns it removes whole rows. Always do it on a copy of the column or sheet: copy the column to an empty place first, then remove duplicates there.

5. UNIQUE: the modern way (Excel 365 and 2021+)

If you have Microsoft 365 or Excel 2021, one function does it all and updates automatically:

Formula Returns
=UNIQUE(B2:B11) Every different value, once (distinct)
=UNIQUE(B2:B11, , TRUE) Only the values that appear exactly once
=SORT(UNIQUE(B2:B11)) The distinct list, sorted A to Z
=COUNTA(UNIQUE(B2:B11)) How many different values there are

UNIQUE spills: you type it in one cell and the results fill the cells below. Leave those cells empty, otherwise you'll get a #SPILL! error.

6. Count the different values in one cell (every version)

Sometimes you don't need the list, only the number. Without UNIQUE, this classic formula does it in any version of Excel:

=SUMPRODUCT(1/COUNTIF(A2:A11, A2:A11))

How it works: for each row, COUNTIF(A2:A11, A2:A11) returns how many times that name appears. Anna appears 4 times, so each of her 4 rows gets 1/4, and together they add up to exactly 1. Every name adds up to 1, however many times it appears. So the total is the number of different names.

{"cells": {"A1": "Customer", "A2": "Anna", "A3": "Boris", "A4": "Anna", "A5": "Clara", "A6": "David", "A7": "Boris", "A8": "Anna", "A9": "Elena", "A10": "Clara", "A11": "Anna", "C1": "Question", "D1": "Answer", "C2": "Different customers", "D2": "=SUMPRODUCT(1/COUNTIF(A2:A11,A2:A11))", "C3": "Ordered only once", "D3": "=SUMPRODUCT(--(COUNTIF(A2:A11,A2:A11)=1))", "C4": "Repeat customers", "D4": "=D2-D3", "C5": "Orders by Anna", "D5": "=COUNTIF(A2:A11,\"Anna\")"}, "focus": "D2", "rows": 12, "note": "Change a name in column A — every answer updates."}

And the number of values that appear only once:

=SUMPRODUCT(--(COUNTIF(A2:A11, A2:A11)=1))

If the column can contain empty cells, the first formula fails with #DIV/0! (an empty cell is counted 0 times, and 1/0 is an error). This version skips the blanks:

=SUMPRODUCT((A2:A11<>"")/COUNTIF(A2:A11, A2:A11&""))

Bonus: a pivot table

Select the data, Insert → PivotTable, and drag the column into Rows. The pivot table lists every distinct value once, and if you also drag it into Values you get how many times each appears. For a quick look at a big list, nothing is faster.

Which method should you use?

You need… Use
To mark first appearances, keeping the order COUNTIF($B$2:B2, B2)=1
Values that appear only once COUNTIF($B$2:$B$11, B2)=1
Speed on a big sorted list =B2<>B1
A one-off list without formulas Advanced Filter
To clean the data itself Remove Duplicates (on a copy)
A list that updates itself (Excel 365) UNIQUE
Just the number of different values SUMPRODUCT(1/COUNTIF(...)) or COUNTA(UNIQUE(...))

Common mistakes

  1. Hidden spaces. "Anna " and "Anna" are two different values for every method here. Clean the column with TRIM first.
  2. Upper and lower case. COUNTIF, Advanced Filter, Remove Duplicates and UNIQUE all ignore case: ANNA and anna are the same value. If case matters, you need EXACT.
  3. The wrong $ in the growing range. $B$2:B2 must have the start locked and the end free. B2:B2 counts only one cell; $B$2:$B$2 never grows.
  4. The cell=cell method on unsorted data. It only works when every repeat is directly under the first one. Sort first.
  5. Numbers stored as text. 1024 and "1024" look the same but count as two different values.
  6. Remove Duplicates on the original. It deletes rows, and Ctrl+Z is your only way back. Work on a copy.

Comparing two lists instead of finding repeats in one? See how to compare two columns in Excel.

Practise it

  • COUNTIF: count the cells that meet a condition
  • IF: turn the result into your own labels
  • SUMPRODUCT: count with conditions in a single cell
  • TRIM: remove the spaces that create false duplicates

Practise the functions from this article

Every function has a short explanation and exercises in a real spreadsheet — your first 3 are free.

Start for free →

More articles

VLOOKUP vs XLOOKUP: 4 Traps That Give Wrong Answers

VLOOKUP can return a balance for an account that does not exist, with no error. Four traps from real banking reports and how XLOOKUP fixes them.

How to Fix Excel Errors: #N/A, #VALUE!, #REF! (Game)

What #N/A, #VALUE!, #REF!, #DIV/0! and #NAME? mean in Excel and how to fix each one. Then beat the clock: fix 10 broken formulas before 5 PM.

Free Loan Amortization Schedule Template for Excel

Download a free Excel loan amortization schedule with extra payments, payoff date, total interest and a balance chart. Type your loan and it updates instantly.