Excel UNIQUE Function: Extract Unique Values and Remove Duplicates

The Excel UNIQUE function returns a list with the duplicates removed. Your original data stays as it is, the list is built somewhere else, and it updates when the source changes. UNIQUE is available in Microsoft 365, Excel 2024, Excel 2021 and Excel for the web, but not in Excel 2019 or older. Every result below was worked out by hand from the 12-row table shown, so you can type it in and compare.

Excel UNIQUE function example: 12 rows reduced to a list of 4 cities
UNIQUE turns a column of repeated cities into a short list

UNIQUE syntax

=UNIQUE(array, [by_col], [exactly_once])

array is the range to check. by_col is optional: FALSE or left out compares rows (the usual case), TRUE compares columns, which you need for a list that runs across a row. exactly_once is optional too: FALSE or left out returns every different value once, TRUE returns only the values that appear a single time. Skipping by_col while setting exactly_once means two commas in a row: =UNIQUE(B2:B13,,TRUE).

Excel UNIQUE function syntax: array, by_col and exactly_once
The three UNIQUE arguments
광고

The example table

Type this into A1:D13 with the headers in row 1. Every formula below uses rows 2 to 13.

A: CustomerB: CityC: ProductD: Amount
2MiaAustinPens120
3NoahBostonPens80
4LiamAustinInk45
5EmmaDenverPens60
6ZoeBostonPaper30
7OwenAustinPens90
8EllaChicagoInk50
9JackBostonPens70
10IvyAustinPaper25
11LeoDenverPens100
12RuthChicagoPens40
13SamBostonInk55

Get a unique list from one column

In F2, type =UNIQUE(B2:B13) and press Enter. Four cities spill down from F2 in the order they first appear: Austin, Boston, Denver, Chicago. Only F2 holds the formula. The cells under it are part of the spill and cannot be edited one by one. Austin and Boston each have 4 rows, Denver and Chicago 2 each, which adds up to the 12 rows in the table.

To sort the list, wrap it: =SORT(UNIQUE(B2:B13)) gives Austin, Boston, Chicago, Denver.

광고

Unique rows across two columns

Give UNIQUE more than one column and a row only counts as a duplicate when every column matches. =UNIQUE(B2:C13) checks city and product together. Mia’s Austin and Pens (row 2) matches Owen’s (row 7), Noah’s Boston and Pens (row 3) matches Jack’s (row 9), and Emma’s Denver and Pens (row 5) matches Leo’s (row 11). Three rows are repeats, so 9 pairs come back.

exactly_once: “unique” means something else here

In everyday talk, “unique values” and “distinct values” mean the same thing. In Excel they do not. The plain UNIQUE call returns the distinct list. The third argument asks for the values that appear only once and drops anything that repeats, even its first appearance.

FormulaReturnsRows
=UNIQUE(B2:B13)Each city once4
=UNIQUE(B2:C13)Each city and product pair once9
=UNIQUE(B2:C13,,TRUE)Pairs that appear once6
=UNIQUE(B2:B13,,TRUE)Cities that appear oncenone: #CALC!
Excel UNIQUE function results: distinct values versus values that appear once
Four UNIQUE formulas on the same 12-row table

Check the 6 by hand: the nine distinct pairs minus the three that appear twice leaves Austin and Ink, Boston and Paper, Chicago and Ink, Austin and Paper, Chicago and Pens, and Boston and Ink. The last row is the trap. Every city appears at least twice, so nothing qualifies and Excel returns #CALC! (an empty array). Wrap it when that can happen: =IFERROR(UNIQUE(B2:B13,,TRUE),"None").

Unique values across a row

Type Red, Blue, Red, Green, Blue, Red into H2:M2. A row of values is a single row to UNIQUE, so =UNIQUE(H2:M2) returns all six cells unchanged. Add TRUE for by_col, =UNIQUE(H2:M2,TRUE), and it compares column by column and returns Red, Blue, Green across three cells.

Count the unique values

=COUNTA(UNIQUE(B2:B13)) returns 4. If the list already sits in F2, point at the whole spill with the hash sign: =ROWS(F2#) also gives 4, and the result keeps up when the list grows or shrinks. For Excel 2019 and older there is a classic formula: =SUMPRODUCT(1/COUNTIF(B2:B13,B2:B13)). Each city adds up to exactly 1 (4 rows at a quarter each, 2 rows at a half each), so the total is 4. It is slow on big ranges and breaks on blank cells, because dividing by a zero count gives #DIV/0!.

Blank cells show up as 0

Say the data will grow to row 20 and you point UNIQUE at B2:B20 ahead of time. Rows 14 to 20 are empty, and the list now has five entries: the four cities plus a 0 for the blanks. Filter the blanks out first:

=UNIQUE(FILTER(B2:B20,B2:B20<>"")) returns the four cities only. This is also the safe form inside a count: =COUNTA(UNIQUE(FILTER(B2:B20,B2:B20<>""))) returns 4, where the plain version would say 5.

Excel UNIQUE function with blank cells: a 0 appears unless you filter first
Filter blanks out before UNIQUE

Use the list: totals and a drop-down

With the city list in F2, type =SUMIF(B2:B13,F2#,D2:D13) in G2. It spills one total beside each city: Austin 280 (120+45+90+25), Boston 235 (80+30+70+55), Denver 160 (60+100), Chicago 90 (50+40). The four add up to 765, the same as the whole Amount column, which is a quick sanity check.

For a drop-down that never needs updating, go to Data, Data Validation, choose List, and enter =$F$2# as the source. New cities appear in the drop-down as soon as they appear in the data.

Capital letters: UNIQUE ignores case, so “Austin” and “austin” count as the same value and the first spelling is kept. Extra spaces do count: “Austin ” with a trailing space is a different value. Clean the column with TRIM first, =UNIQUE(TRIM(B2:B13)), when data comes from copy and paste.

UNIQUE errors and fixes

#SPILL! means something already sits in the cells the list needs, such as a stray value or a merged cell. Clear that space and the list appears. #NAME? usually means the Excel version has no UNIQUE (2019 or older), or the name is misspelled. #CALC! means the result is empty, which happens with exactly_once when nothing appears only once. #REF! can appear if UNIQUE points at another workbook that is closed. A formula that spills cannot live inside an Excel Table, so put it in a normal cell next to the table instead.

Google Sheets and older Excel

Google Sheets has the same function with the same three arguments in the same order, =UNIQUE(B2:B13), and returns rows in the order they first appear. There is no hash sign in Sheets. To refer to a spilled list, use an open range such as F2:F. In Excel 2019 or older, use Data, Remove Duplicates. It deletes the repeats in the original, so work on a copy of the column.

Excel UNIQUE function checklist before you share a file
Five checks for a UNIQUE formula

Frequently asked questions

What does the UNIQUE function do in Excel?

It returns the different values of a range, each one once, and spills them into the cells below. =UNIQUE(B2:B13) turns twelve rows of cities into a list of four.

How do I get only values that appear once?

Set the third argument to TRUE: =UNIQUE(B2:C13,,TRUE). Values that repeat are dropped completely. If nothing appears once, the result is #CALC!.

Why does my UNIQUE list end with a 0?

The range contains blank cells and UNIQUE returns them as 0. Remove them first with =UNIQUE(FILTER(B2:B20,B2:B20<>"")).

Is UNIQUE case sensitive?

No. “Austin” and “austin” are treated as the same value. Extra spaces are not ignored, so use TRIM on messy data.

Which Excel versions have UNIQUE?

Microsoft 365, Excel 2024, Excel 2021 and Excel for the web. Excel 2019 and older show #NAME?.

Sources: Last checked November 2026. Microsoft Support: UNIQUE function; Exceljet: UNIQUE; Google: UNIQUE in Google Sheets.

광고

#ExcelUNIQUE  #UNIQUEFunction  #RemoveDuplicates  #DistinctValues  #ExcelFormulas  #DynamicArrays  #SpillRange  #GoogleSheets  #ExcelTips  #MetaTrend

Found this useful? Share it.