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.
| Version | Has it |
|---|---|
| Microsoft 365 (Windows and Mac) | Yes |
| Excel for the web | Yes |
| Excel 2024 | Yes |
| Excel 2021 | Yes |
| Excel 2019 | No |
| Excel 2016 | No |
Google Sheets
Google Sheets has UNIQUE with the same three arguments (range, by_column, exactly_once).
Examples
The examples use this sample sheet.
| Row | A | B | C | D | E |
|---|---|---|---|---|---|
| 1 | Order ID | Rep | Region | Product | Amount |
| 2 | 1001 | Ana | North | Laptop | 1200 |
| 3 | 1002 | Ben | South | Monitor | 300 |
| 4 | 1003 | Ana | North | Monitor | 350 |
| 5 | 1004 | Cara | East | Laptop | 1150 |
| 6 | 1005 | Ben | South | Laptop | 1250 |
| 7 | 1006 | Dev | West | Keyboard | 80 |
| 8 | 1007 | Cara | East | Monitor | 320 |
| 9 | 1008 | Ana | South | Keyboard | 90 |
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.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.Count distinct values
=COUNTA(UNIQUE(D2:D9))Result: 3
Laptop, Monitor and Keyboard.
Common errors and fixes
| Error | Why it happens | Fix |
|---|---|---|
| #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.
List every distinct customer and how many orders each placed.
Done. I used UNIQUE on your sheet and checked the results against your data.
- Written for your platform and version
- Checked against your actual data
- Newest functions looked up in official docs
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