Count how many distinct values are in a range using UNIQUE + COUNTA.
Copy this formula
=COUNTA(UNIQUE(A2:A100))UNIQUE returns the distinct values from a range, and COUNTA counts how many there are. This works in Excel 365 and Excel 2021. In older versions, use a SUMPRODUCT/COUNTIF combination.
=COUNTA(UNIQUE(B2:B500))→37There are 37 distinct customers in the list.
=COUNTA(UNIQUE(FILTER(A2:A100, A2:A100<>"")))→24Ignores blank cells, which UNIQUE would otherwise count as one value.
=SUM(--(COUNTIF(A2:A100, A2:A100)=1))→9Counts only the values that appear exactly once.
Legacy (pre-365)
=SUMPRODUCT(1/COUNTIF(A2:A100, A2:A100))Works without UNIQUE; the range must not contain blanks.
Blank cells cause a divide-by-zero. Restrict the range to filled cells or wrap COUNTIF criteria to skip blanks.
A distinct count takes each different value once. Strictly, unique means values that appear only once. =COUNTA(UNIQUE(range)) gives the distinct count; UNIQUE(range, , TRUE) keeps only values that occur exactly once.
Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. Earlier versions need the SUMPRODUCT/COUNTIF formula.
Filter first: =COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="East"))).
Need a formula for your own data?
Describe what you want in plain language and let ExcelGPT write, explain, and verify the formula — free to start, no plugin.