How to use UNIQUE in Excel
UNIQUE returns a list of the distinct values in a range, in one formula. The result spills into the cells below and updates itself when the data changes.
Syntax
=UNIQUE(array, [by_col], [exactly_once])
array | The range to take the values from, e.g. A2:A500. |
[by_col] | Optional. TRUE compares columns instead of rows. Usually left out. |
[exactly_once] | Optional. TRUE returns only the values that appear exactly once. |
Examples
=UNIQUE(A2:A500)Every city once.=SORT(UNIQUE(A2:A500))The same list from A to Z.=COUNTA(UNIQUE(A2:A500))How many different cities there are.=UNIQUE(A2:A500, , TRUE)Cities that appear only once.A clean list for a report
Instead of copying a column and running Remove Duplicates every month, one UNIQUE formula keeps the list up to date. Wrap it in SORT for a tidy order.
=SORT(UNIQUE(B2:B500))Every client once, A to Z.=UNIQUE(A2:B500)Unique combinations of two columns, like branch and product.A summary table in two formulas
UNIQUE gives the labels, SUMIF gives the totals. Point SUMIF at the spilled list with # and the table grows by itself.
=UNIQUE(A2:A500)In E2: every region.=SUMIF($A$2:$A$500, E2, $C$2:$C$500)In F2, copied down: the total for each region. In Microsoft 365, E2# refers to the whole spilled list, so one formula fills the column.Common mistakes
- #SPILL! error
- The cells below the formula aren't empty. Clear them, even a single space blocks the result.
- #NAME? error
- Excel 2019 and older don't have UNIQUE. Use Data → Remove Duplicates on a copy instead.
- Blank cells show as 0
- Empty cells in the range become a 0 in the list. Filter them out:
=UNIQUE(FILTER(A2:A500, A2:A500<>"")).
Frequently asked questions
How do I remove duplicates in Excel?
With a formula: =UNIQUE(A2:A500). Without one: select the data and use Data → Remove Duplicates (it changes the data itself). More ways in find unique values in Excel.
Why does UNIQUE return #SPILL!?
The cells under the formula aren't empty. The list needs free space to spill into.
How do I count unique values?
=COUNTA(UNIQUE(A2:A500)). In older Excel: =SUMPRODUCT(1/COUNTIF(A2:A500, A2:A500)).
Is UNIQUE case-sensitive?
No. "Sofia" and "SOFIA" count as the same value.
Available in: Microsoft 365, Excel 2021 and newer, Excel for the web, Google Sheets