How to count unique values with UNIQUE and COUNTA
This counts how many different names are in a column, rather than how many rows. Repeats are counted once.
The formula
=COUNTA(UNIQUE(A:A)) in column C
What each part does
UNIQUEStrips the list down to one of each value.
COUNTACounts what is left.
How it works, and what to watch for
UNIQUE gathers one of each, and COUNTA counts what is left. Together they answer "how many different", not "how many rows".
UNIQUE needs Microsoft 365. On older Excel the same count comes from a SUMPRODUCT with COUNTIF, which the version switch will give you.
Blank cells can sneak in as one of the "unique" values, so trim the range to the rows that actually hold data if the count looks one too high.
Questions
How do I list the different values, not just count them?
Use UNIQUE on its own and it spills the distinct list down the column. Wrap it in SORT to put them in order.
No UNIQUE on my Excel, what now?
The classic version is =SUMPRODUCT(1/COUNTIF(range,range)), which counts the distinct values without needing UNIQUE.
The example sheet
Customer
Different customers
Acme
Bellrose
Acme
Larkspur
If this helped, these are close by
When this formula goes wrong
More on UNIQUE , and every walkthrough that uses it.
Formula List
Formula Fixer
Formula List
Settings: separator, Excel version
Argument separator
Set by your computer's language, not by the file. A frequent cause of a correct-looking formula being rejected.
Comma =SUM(A1,B1)
Semicolon =SUM(A1;B1)
Excel version
XLOOKUP, IFS, TEXTBEFORE and TEXTJOIN need Microsoft 365 or 2021; older versions return #NAME? instead. Choosing the older one switches every walkthrough to a formula that works there.
Microsoft 365 or 2021
2019 or earlier
Is a formula returning an error?
Paste it below for a line-by-line check.
Check the formula
Clear
or press Enter
Try one of these
© Formula Steps — formulasteps.com
Bookmark
Share