UNIQUE in Excel: 6 Practical Uses (And How to Stop the Zero at the Bottom)

UNIQUE in Excel: 6 Practical Uses (And How to Stop the Zero

UNIQUE in Excel: 6 Practical Uses (And How to Stop the Zero at the Bottom)

UNIQUE returns the distinct values of a range, without repeats, using a formula instead of the Remove Duplicates command. The difference matters: Remove Duplicates deletes rows from your data, while UNIQUE leaves the source alone and refreshes when the data changes. Here are six uses that cover most real work, plus the two problems people hit on the first day.

What it returns

Give it a range and it returns the values that appear, once each, in the order they are first found. It is a dynamic array, so the result spills down from the cell where you typed it. Nothing below or to the right of that cell can be occupied, or you get #SPILL!. If the range is a formatted table, the formula follows the table as it grows.

Use 1: a clean list from a messy column

Two thousand orders in A2:A2000 with the customer name repeated on every row. In D2: =UNIQUE(A2:A2000). You get one row per customer, ready to use in a dropdown, a lookup table or a report header. This is the case that replaces the weekly copy, Remove Duplicates, paste routine.

If you invoice clients or run a small shop, the ready-made Excel sales invoice template and bookkeeping ledger saves building the file from scratch: Excel invoice and bookkeeping template - a product in our store.

Use 2: count how many there are

Wrap it in ROWS: =ROWS(UNIQUE(A2:A2000)) gives the number of distinct customers without printing the list anywhere. The older formula, =SUM(1/COUNTIF(A2:A2000;A2:A2000)), still works but is harder to read and fails on blank cells. If you only need the count, ROWS is the shorter and safer route.

Use 3: unique pairs, not just single values

Select two columns and UNIQUE compares whole rows: =UNIQUE(A2:B2000) returns each customer and city combination once. The same customer in two cities appears twice, which is correct when the city is part of the key. This is how you build a clean dimension table for a pivot.

Use 4: unique values from filtered rows

Combine with FILTER: =UNIQUE(FILTER(B2:B2000;D2:D2000>500)) lists the regions with at least one sale above 500, each once. Each function does one job and the pair reads left to right: filter first, then deduplicate.

Use 5: unique and sorted

Wrap in SORT: =SORT(UNIQUE(A2:A2000)) gives an alphabetical list that updates itself. Add a direction argument for descending order. Without this, the list appears in the order of first appearance, which is rarely the order anyone wants to read.

Use 6: values that appear only once

The third argument is the one almost nobody knows: =UNIQUE(A2:A2000;FALSE;TRUE) returns only the values that appear exactly once, leaving out the repeated ones. In a month of sales it answers a different question: which products sold once and never again. For the opposite, values that repeat, a COUNTIF column next to the list does the job.

The zero at the bottom of the list

If your range includes blank cells, UNIQUE treats each blank as a value and returns it as 0. That zero then flows into counts and averages and nobody knows where it came from. Three fixes: end the range where the data ends, filter blanks first, or point the formula at a table so the range grows only with real rows. The table is the one that keeps working next month.

Values that look the same and are not

A name with a trailing space and the same name without it are two different values, and the list shows both. Before you trust the list, clean the source with TRIM, or add a helper column and deduplicate that. A list with invisible duplicates looks correct and breaks every lookup built on it. The quick check: compare the row count of the source with the row count of the list, and if the gap is bigger than you expected, look for spaces and hidden characters before anything else.

UNIQUE or Remove Duplicates?

You needUseWhy
A list that refreshes with the dataUNIQUEIt is a formula and recalculates
To permanently clean the source tableRemove DuplicatesChanges the data, leaves no formula
Counts and totals per categoryPivot tableGroups and sums in one step
A unique list from a subsetUNIQUE with FILTERCombines both ideas

Performance and older versions

UNIQUE needs Microsoft 365 or Excel 2021 and later. Pointed at a whole column, it recalculates over a million cells on every change, so keep the range tight or use a table. In older versions the name does not exist and the formula returns #NAME?, where Remove Duplicates or a pivot is the practical answer.

Test it in two minutes

Add a new value to the source and check whether the list grows. Then check the last cell of the list: if it is a zero, your range includes blanks. Both checks take less time than explaining to someone why the customer count is one too high.

Read next

The five ways a SUM goes wrong are the same five reasons a list looks right and is not: see SUM in Excel: The Five Ways People Sum Wrong.

A worked example

Five order rows: Cairo, Giza, Cairo, Alexandria, Giza. =UNIQUE(A2:A6) returns Cairo, Giza, Alexandria, in that order, three rows. =ROWS(UNIQUE(A2:A6)) returns 3. =SORT(UNIQUE(A2:A6)) returns Alexandria, Cairo, Giza. Now add a blank row at the end and the list grows to four with a 0 at the bottom, which is exactly the problem described above.

Add a fifth value, Aswan, and the list becomes four cities with no editing. That is the point of the formula: the report does not need a monthly rebuild.

Mistakes people make

MistakeWhat you seeFix
Range runs past the dataA 0 at the end of the listTrim the range or use a table
Copying the result elsewhereThe list stops updatingKeep the formula, do not paste as values
Unclean textDuplicates that look identicalClean with TRIM first
Dragging the formula downOverlapping blocks or #SPILL!One formula only

When a pivot table wins

If the next step is a total per category, a pivot table does the grouping and the summing in one object, and it refreshes with a click. UNIQUE gives you the list and nothing else, so you still need SUMIF beside it. Use UNIQUE when the list itself is the deliverable, and a pivot when the numbers are the point. Mixing the two in one sheet is where most maintenance time goes.

One note for shared files

Anyone on Excel 2019 or older sees #NAME? where the list should be. If the file travels, copy the block and paste it as values into a separate sheet before sending, and keep the live formula in a working sheet.

Unique values across two sheets

UNIQUE takes one range, so it cannot merge two sheets by itself. The practical route is to stack them first: =UNIQUE(VSTACK(Sheet1!A2:A500;Sheet2!A2:A500)), which joins the two columns into one list and then deduplicates. In versions without VSTACK, copy both columns into a helper sheet and point UNIQUE at that.

Is it case sensitive?

No. UNIQUE treats North and north as the same value and returns whichever appears first. That is usually what you want for a report, and it is also why a list can look shorter than the data suggests. If case matters, add a helper column with EXACT comparisons before deduplicating.

Official source

Full arguments and examples: UNIQUE function. For sorting the result: SORT function. For filtering first: FILTER function.

Get new guides by email
One short email when a new guide is published. No spam, and you can leave anytime.
Your address is only used for these emails.

Last updated: 5 December 2026

Comments

Popular posts from this blog

Learn to Code From Zero: A 90-Day Plan That Survives a Full-Time Job

How to Read Your Payslip: Gross, Net, Tax Codes and the YTD Column

iPhone Storage Full? What to Delete First (And What Never to Touch)