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.
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.
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.