Home  /  Blog  /  Lookup & Filter
Lookup & Filter

UNIQUE Function in Excel — With Examples (Unique Values, Exactly Once, Count)

By admin 28 November 2026 Lookup & Filter

Your Region column has ten rows and four regions — East, West, North, South — with East written four times and West three. You need the clean list: each region once, in the order it first appears, and you need it to update itself when the data changes. That is the UNIQUE function: =UNIQUE(B2:B11). You type it once, in one cell, and the list spills down below it. This guide gives you that formula first, then runs it on the ten-order sales table, so you can check each answer yourself — the distinct list, the values that appear exactly once, the count, the blank case, the sorted list, and the two-column case — plus the #SPILL! and #NAME? fixes, and the older-Excel method.

Quick takeaway: one formula, typed once, spills the whole list.

  • =UNIQUE(B2:B11) — each distinct value once, in the order it first appears.
  • =UNIQUE(B2:B11,,TRUE) — only the values that appear exactly once.
  • Count them: =COUNTA(UNIQUE(B2:B11)) — COUNTA, not COUNT, for text.
  • Blank in the source? It shows as 0 — filter it out first.
  • Spill cells must be empty, or you get #SPILL!. Excel 2019 and earlier give #NAME?.
UNIQUE Function in Excel — With Examples (Unique Values, Exactly Once, Count)

The Syntax — Three Arguments, One Required

=UNIQUE(array, [by_col], [exactly_once])
ArgumentRequiredWhat it does
arrayYesThe range or array you want the distinct values from
by_colNoFALSE (the default) compares rows; TRUE compares columns, for data that runs across a row
exactly_onceNoFALSE (the default) returns one of every distinct value; TRUE returns only the values that appear exactly once

The two optional arguments are positional. To set exactly_once without by_col, leave an empty slot with an extra comma: =UNIQUE(B2:B11,,TRUE).

The Worked Table — The Distinct List

Every example below uses the same ten-order sales table from the COUNTIF, SUMIF and Highlight Row articles — Rep, Region, Sales, Order Date, Status, Notes — in rows 2 to 11. Every result was counted against it.

FormulaResult (spills down)Count
=UNIQUE(B2:B11) — RegionsEast, West, North, South4
=UNIQUE(A2:A11) — RepsAlex, Priya, Jordan, Sam, Taylor5
=UNIQUE(E2:E11) — StatusPaid, Pending2
=SORT(UNIQUE(B2:B11)) — Regions, A to ZEast, North, South, West4

Read the rows. The Regions list has 4 values, not 5 — and that is the case trap. Row 4 has the region written “east” in lowercase, and UNIQUE is not case-sensitive: “east” and “East” count as the same value, so only the first one, “East”, appears in the list. Extra spaces are different, though — “East ” with a trailing space is not “East” — so clean the data with TRIM first. And the list is in the order each value first appears, not A to Z — wrap it in SORT for the alphabetical list.

Exactly Once — The Values That Appear a Single Time

“Unique” means two different things, and UNIQUE does both. By default it returns the distinct values — every region once, however many orders it had. Set exactly_once to TRUE and it returns only the values that appear exactly once:

FormulaResultCount
=UNIQUE(B2:B11,,TRUE) — Regions appearing onceSouth1
=UNIQUE(A2:A11,,TRUE) — Reps appearing onceTaylor1

South appears once in the ten orders, so it is the only region in the exactly-once list. Taylor is the only rep with one order — Alex has 3, Priya 2, Jordan 2 and Sam 2. Exactly once is strict: any duplicate count breaks the value. That is what makes it useful for spotting one-off entries — a customer who ordered a single time, or an invoice ID that appears once when it should appear twice.

Count the Unique Values — COUNTA, Not COUNT

FormulaResultWhy
=COUNTA(UNIQUE(B2:B11)) — distinct regions4COUNTA counts the items in the spilled list
=COUNTA(UNIQUE(A2:A11)) — distinct reps5The same, on the Rep column
=COUNT(UNIQUE(B2:B11))0COUNT only counts numbers, so it returns 0 for a list of names

Use COUNTA, not COUNT: COUNT only counts numbers, so it returns 0 for a list of names. If the list is already on the sheet, you can count it with a spill reference — the first cell of the spill followed by #. With the regions spilled from H2, =COUNTA(H2#) returns 4. Unlike a fixed range such as H2:H5, H2# grows and shrinks with the list, so the count stays right when a new region appears. To count distinct values that meet a condition, filter first: =COUNTA(UNIQUE(FILTER(A2:A11, B2:B11="East"))) returns 3 — the number of different East reps: Alex, Jordan and Priya.

Blanks — The 0 at the Bottom

The Notes column has 4 blank cells and 6 filled ones — Rush 3 times, Gift wrap, Call first and Delivery once each:

FormulaResultCount
=UNIQUE(F2:F11) — Notes, blanks includedRush, 0, Gift wrap, Call first, Delivery5
=UNIQUE(FILTER(F2:F11, F2:F11<>"")) — Notes, blanks excludedRush, Gift wrap, Call first, Delivery4

The blank shows as a 0 at the bottom of the list — UNIQUE returns 0 for the empty cells in the range. Filter the blanks out first with =UNIQUE(FILTER(F2:F11, F2:F11<>"")) and the 0 is gone. The same FILTER pattern is the one to use when the range runs past the last entry.

Two Columns at Once — Unique Combinations

Give UNIQUE more than one column and it compares whole rows — a row counts as a duplicate only when all its values match:

FormulaResultCount
=UNIQUE(B2:E11) — Region + Status pairsEast/Paid, West/Pending, North/Paid, East/Pending, South/Paid5

Ten orders, five distinct Region-and-Status pairs. Alex’s East/Paid order and Taylor’s East/Paid order are the same pair, so they appear once. And a rep who bought in two regions would appear twice, once per region — Priya appears as West/Pending and East/Pending, two different pairs.

Unique Values Across a Row — by_col

When the values run across a row instead of down a column, set by_col to TRUE:

=UNIQUE(B2:G2, TRUE)

On the row East, West, East, North, West, South that returns East, West, North, South — spilling to the right instead of down. With several columns and by_col left out, UNIQUE compares rows; with by_col TRUE it compares columns. You will rarely need it — most lists run down a column — but when the data runs across, it is the only argument that changes.

Older Excel — No UNIQUE? Remove Duplicates, or COUNTIF

UNIQUE works in Microsoft 365, Excel 2024, and Excel 2021 (Windows and Mac), and in Excel for the web. Excel 2019 and earlier do not have it and show a #NAME? error. Two ways round it:

  • Remove Duplicates (one-off list): copy the column somewhere safe, select it, and choose Data > Remove Duplicates. It deletes the repeats from those cells, so never run it on your only copy of the data. The list is static — it does not update when the source changes.
  • Count unique values (older Excel): =SUMPRODUCT(1/COUNTIF(B2:B11, B2:B11)) returns 4 — the same count as COUNTA(UNIQUE(…)). It works because each East row contributes 1/4, each West row 1/3, each North row 1/2 and the South row 1/1, and 1/4 + 1/4 + 1/4 + 1/4 + 1/3 + 1/3 + 1/3 + 1/2 + 1/2 + 1 = 4.

Common Mistakes

MistakeWhat happensFix
You used COUNT instead of COUNTA0 — COUNT only counts numbersUse =COUNTA(UNIQUE(...))
You forgot the spill space#SPILL! — a cell in the way is not emptyClear the cells below the formula
You used UNIQUE in old Excel#NAME? — the function does not exist thereUse Remove Duplicates, or the SUMPRODUCT count
You forgot the empty slot=UNIQUE(B2:B11, TRUE) sets by_col, not exactly_onceUse two commas: =UNIQUE(B2:B11,,TRUE)
You expected A-to-Z orderUNIQUE keeps the order of first appearanceWrap it in SORT: =SORT(UNIQUE(...))
You left blanks in the rangeA 0 appears at the bottom of the listFilter them out: =UNIQUE(FILTER(range, range<>""))
You counted on the spill with a fixed rangeThe count goes wrong when the list growsUse the spill reference: =COUNTA(H2#)

Frequently Asked Questions

How do I get unique values from a column in Excel? =UNIQUE(B2:B11) — type it once in one cell, and the distinct values spill down below it, in the order they first appear.

What is the difference between unique and exactly once? By default UNIQUE returns one of every distinct value. With exactly_once TRUE — =UNIQUE(B2:B11,,TRUE) — it returns only the values that appear a single time.

How do I count unique values in a column? =COUNTA(UNIQUE(B2:B11)) — COUNTA, not COUNT, because COUNT only counts numbers. On the Regions column that returns 4.

Why does my unique list show a 0 at the bottom? Your range contains empty cells, which UNIQUE returns as 0. Filter them out: =UNIQUE(FILTER(B2:B11, B2:B11<>"")).

Why do I get #SPILL!? The cells where the result needs to go are not empty. Clear them and the list appears.

Is UNIQUE case-sensitive? No. Values that differ only in upper and lower case are treated as the same — “east” and “East” count as one value. Extra spaces are different, so clean the data with TRIM first.

What if my Excel does not have UNIQUE? It needs Microsoft 365, Excel 2024 or Excel 2021. In older Excel, use Data > Remove Duplicates for a one-off list, or =SUMPRODUCT(1/COUNTIF(range, range)) to count.

That is the UNIQUE function in Excel: =UNIQUE(B2:B11) types once and spills the whole distinct list — East, West, North, South from ten orders — in the order each value first appears, and the list updates itself when the data changes. On the table in this guide, that one formula answers every question: the distinct regions are 4, the distinct reps are 5, the values appearing exactly once are South and Taylor, the count is =COUNTA(UNIQUE(...)) — 4 for regions, 5 for reps — and the blanks are a 0 until you filter them out. Remember the two things that catch everyone once: UNIQUE is not case-sensitive, so “east” and “East” are one value, while a trailing space makes a different one — and the spill cells must be empty, or you get #SPILL!. In older Excel there is no UNIQUE: Remove Duplicates for a one-off list, or =SUMPRODUCT(1/COUNTIF(range, range)) for the count. From here, the next functions worth learning are the ones this one sits next to — the FILTER function for the filter inside the blank-free list, the XLOOKUP function for looking up the values once you have them — and the full learning order for the whole site is on the Excel Formulas hub and the Lookup topic page.


About admin

Author of Excel formula guides on this blog.

View all guides by admin →

Keep Learning

Related guides