Excel functions · Dynamic arrays

UNIQUE function in Excel

UNIQUE returns the distinct values from a range, removing duplicates, as a live list that updates when the data changes. With its third argument set to TRUE it returns only the values that appear exactly once.

Last reviewed

Syntax

=UNIQUE(array, [by_col], [exactly_once])
arrayrequired
The range to take values from. Several columns return unique combinations.
by_coloptional
FALSE compares rows (the default); TRUE compares columns.
exactly_onceoptional
FALSE returns every distinct value (the default); TRUE returns only values that occur once.
  • The result spills: type the formula in one cell and it fills as many cells as it needs, and it updates when the data changes.
  • Values come back in the order they first appear. Wrap in SORT for A–Z.
  • Comparison ignores case: "north" and "North" count as one.

Which versions have UNIQUE

Microsoft 365, Excel for the web, and Excel 2021 or later (Windows and Mac). Not in Excel 2019 or 2016.

UNIQUE availability by Excel version
VersionHas it
Microsoft 365 (Windows and Mac)Yes
Excel for the webYes
Excel 2024Yes
Excel 2021Yes
Excel 2019No
Excel 2016No

Google Sheets

Google Sheets has UNIQUE with the same three arguments (range, by_column, exactly_once).

Examples

The examples use this sample sheet.

Orders (A1:E9)
RowABCDE
1Order IDRepRegionProductAmount
21001AnaNorthLaptop1200
31002BenSouthMonitor300
41003AnaNorthMonitor350
51004CaraEastLaptop1150
61005BenSouthLaptop1250
71006DevWestKeyboard80
81007CaraEastMonitor320
91008AnaSouthKeyboard90
  1. 1.Distinct regions

    =UNIQUE(C2:C9)

    Result: Spills North, South, East, West

    North
    South
    East
    West

    Each region once, in the order it first appears.

  2. 2.Values that appear exactly once

    =UNIQUE(B2:B9, FALSE, TRUE)

    Result: Dev

    Ana has three orders and Ben and Cara two each; only Dev appears once.

  3. 3.Count distinct values

    =COUNTA(UNIQUE(D2:D9))

    Result: 3

    Laptop, Monitor and Keyboard.

Common errors and fixes

UNIQUE errors, causes and fixes
ErrorWhy it happensFix
#CALC!exactly_once is TRUE and every value appears more than once, so the result is empty.Wrap it in IFERROR to show a message.
#SPILL!The result needs more cells than are free: something is in the way, or the formula is inside an Excel table.Clear the cells below and to the right, or move the formula outside the table.
#NAME?Your Excel doesn't have dynamic array functions (Excel 2019 or older).Open the file in Microsoft 365, Excel for the web, or Excel 2021 or later.

Do it with GPTExcel

Skip writing UNIQUE by hand

Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.

your-file.xlsx

List every distinct customer and how many orders each placed.

Done. I used UNIQUE on your sheet and checked the results against your data.

your-file-updated.xlsxYour original stays unchanged
  • Written for your platform and version
  • Checked against your actual data
  • Newest functions looked up in official docs
Try it free Formula Generator

Free plan, no credit card.

UNIQUE questions

How do I count unique values in Excel?
Wrap UNIQUE in COUNTA: =COUNTA(UNIQUE(D2:D9)) returns 3 for the three products in the sample data.
Is UNIQUE case-sensitive?
No. UNIQUE treats "North" and "north" as the same value and keeps the first one it finds.

Skip the formula hunt

Upload a spreadsheet and ask in plain English. Free plan, no credit card.

Start free