Counting how many distinct values appear in a list — unique customers, unique products, unique visitors — is trivial in modern Excel with COUNTA(UNIQUE(…)), and still doable in any version with a classic SUMPRODUCT/COUNTIF trick.
A2:A10:
UNIQUE returns the de-duplicated list; COUNTA counts how many items came back.
The example
A list of orders with the customer on each row. Five names appear, but only three are distinct.
| A | B | |
|---|---|---|
| 1 | Customer | Amount |
| 2 | Acme | $120 |
| 3 | Bolt | $80 |
| 4 | Acme | $200 |
| 5 | Cedar | $50 |
| 6 | Bolt | $300 |
| 7 | Distinct customers: | 3 |
The formula
The count of distinct customers is:
How it works
Two functions working as a pair:
UNIQUE(A2:A6)returns each customer once: Acme, Bolt, Cedar — spilling into three cells.COUNTAcounts the non-empty items in that spilled list —3.- Wrap the list in
FILTERfirst to count distinct values that also meet a condition (see Variations).
Try it: interactive demo
Type a comma-separated list. The unique count and both formulas update as you type.
Variations
Count distinct values that meet a condition
Distinct customers in the West region only — filter first, then de-duplicate:
Legacy version (any Excel, no UNIQUE)
The classic array trick — divide 1 by each value’s count and sum the pieces:
Ignore blanks in the legacy formula
Blanks cause a divide-by-zero. Guard them:
Pitfalls & errors
UNIQUE counts blanks as a value. An empty cell in the range shows up as one "unique" blank. Filter them out: =COUNTA(UNIQUE(FILTER(A2:A6, A2:A6<>""))).
#DIV/0! in the SUMPRODUCT version. A blank cell makes COUNTIF return 0 and the division fails. Use the blank-guarded form shown above.
"Unique" vs "distinct". UNIQUE(range, , TRUE) returns values that appear exactly once (true uniques); the default returns each value once (distinct). For a normal "how many different" count, use the default.
Practice workbook
Frequently asked questions
How do I count unique values in Excel without UNIQUE?
What's the difference between unique and distinct?
How do I count distinct values with a condition?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class