WP Workflow Picks
excelformulasunique

Excel Count Unique Values in a Column: 4 Methods That Work

How to count unique values in an Excel column with COUNTA and UNIQUE, a SUMPRODUCT/COUNTIF formula for older versions, a PivotTable distinct count and handling blanks.

WP Workflow Picks team · · 6 min read · 5 sources
Churchill Club Top 10 Tech Tech Trends Debate 2013 — I chose Deep Learning / Machine Learning
Photo: jurvetson (CC BY 2.0) via Openverse

To count the unique values in a column in Microsoft 365, Excel 2024 or Excel 2021, use =COUNTA(UNIQUE(A2:A100)). It counts each different value once. In older versions, =SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100)) gives the same result, as long as the range has no blank cells.

There are a few catches, mostly blank cells, case sensitivity and what “unique” actually means. The sections below cover each method, when to use it, and how to deal with those catches.

First: do you mean “distinct” or “truly unique”?

The word “unique” means two different things, and Excel can do both:

  • Distinct count: how many different values there are. For Red, Blue, Red, Green that’s 3. Most people searching for this want the distinct count.
  • Exactly-once count: how many values appear only once. For the same list that’s 2 (Blue and Green).

Excel’s UNIQUE function covers both through its optional exactly_once argument, explained below.

Method 1: COUNTA + UNIQUE (Microsoft 365, Excel 2024, Excel 2021)

This is the simplest and most readable option if your version supports it. As of November 2026, Microsoft lists UNIQUE as available in Excel for Microsoft 365 (Windows and Mac), Excel 2024 and Excel 2021. Excel 2019 and earlier do not have it.

The syntax

Microsoft documents the function as:

=UNIQUE(array, [by_col], [exactly_once])

  • array: the range to check, e.g. A2:A100.
  • by_col: leave it out (or use FALSE) to compare rows, which is what you want for a single column.
  • exactly_once: leave it out (or use FALSE) to return every distinct value. Use TRUE to return only the values that appear exactly once.

Steps

  1. Click an empty cell outside your data.
  2. Type =COUNTA(UNIQUE(A2:A100)), replacing A2:A100 with your column range (leave out the header).
  3. Press Enter.

To count only the values that appear exactly once, skip by_col with two commas:

=COUNTA(UNIQUE(A2:A100,,TRUE))

See the list, not just the count

If you want to check which values are being counted, put =UNIQUE(A2:A100) in a cell on its own. The results spill down into the cells below. Those cells need to be empty, or you’ll get a #SPILL! error.

Handling blank cells

This is the most common reason the count is off by one. UNIQUE treats an empty cell as a value (it shows as 0 in the spilled list), and COUNTA counts it. To leave blanks out, filter them first, as Ablebits shows:

=COUNTA(UNIQUE(FILTER(A2:A100, A2:A100<>"")))

One more catch: if FILTER finds nothing (for example, the whole range is empty, or you added a condition that nothing meets), it returns a #CALC! error, and COUNTA counts that error as 1. If that can happen, use ROWS with IFERROR instead:

=IFERROR(ROWS(UNIQUE(FILTER(A2:A100, A2:A100<>""))), 0)

Method 2: SUMPRODUCT + COUNTIF (works in older versions)

If you’re on Excel 2019, 2016 or earlier, or you’re sending the file to someone who is, this formula works without dynamic arrays:

=SUMPRODUCT(1/COUNTIF(A2:A100, A2:A100))

How it works

COUNTIF counts how often each value appears. A value that appears three times gets 1/3 on each of its three rows, and those add up to 1. So every distinct value adds exactly 1 to the total, however many times it repeats. SUMPRODUCT adds it all up without needing Ctrl+Shift+Enter.

The blank-cell problem

As Exceljet explains, any empty cell in the range makes this formula return #DIV/0!. The fix that also leaves blanks out of the count is:

=SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100, A2:A100&""))

The &"" stops the division-by-zero error. The (A2:A100<>"") part turns the numerator into 0 for empty cells so they don’t count.

A note on speed

COUNTIF here compares every cell against every other cell, so the work grows quickly as the range gets bigger. It’s fine for a few thousand rows. On much larger sheets it can slow recalculation, and a PivotTable or UNIQUE is usually the better choice. I haven’t seen an official row-count threshold, so treat this as a rule of thumb.

Method 3: PivotTable with Distinct Count (no formulas)

If you’d rather click than type, a PivotTable can count distinct values. The catch is that Distinct Count only appears when the PivotTable uses the Data Model. In a regular PivotTable the option simply isn’t there. A Microsoft Q&A answer confirms this.

Steps (Excel for Windows)

  1. Click any cell in your data.
  2. Go to Insert > PivotTable.
  3. In the dialog, tick Add this data to the Data Model, then click OK.
  4. Drag your column into the Values area.
  5. Right-click a value in the PivotTable, choose Summarize Values By > More Options, and pick Distinct Count.

Limitations

  • You can’t convert an existing ordinary PivotTable to the Data Model. You have to build a new one with the box ticked.
  • Several users and guides report that the Data Model checkbox is missing in Excel for Mac, so this method may not be available there. On a Mac, use Method 1 or 2.
  • The Data Model isn’t saved in CSV files, so save as .xlsx.
  • PivotTables don’t update on their own. Refresh after you add rows.

Method 4: Advanced Filter + ROWS, or Microsoft’s FREQUENCY formula

Microsoft’s own article on counting unique values among duplicates describes two classic approaches that work in older versions:

  • Advanced Filter: copy only the unique records to a new location (Data > Advanced, with “Unique records only” ticked), then count them with ROWS. For example, =ROWS(B2:B45) if the extracted list sits in B2:B45 without its header.
  • A nested array formula that combines IF, SUM, FREQUENCY, MATCH and LEN. It works, but Microsoft notes it has to be entered as an array formula in older versions, and FREQUENCY ignores text and zero values on their own, which is why the formula is built around MATCH. For most people, Method 2 is easier to read and maintain.

The Advanced Filter result is a static copy. It won’t update when the source data changes.

Which method should you use?

MethodExcel versionsUpdates automaticallyBest for
COUNTA(UNIQUE())Microsoft 365, 2024, 2021YesMost people on current Excel
SUMPRODUCT(1/COUNTIF())All modern versionsYesShared files, older Excel
PivotTable Distinct CountWindows; Data Model requiredAfter refreshLarge data, counts by category
Advanced Filter + ROWSAll versionsNoOne-off checks

Gotchas worth knowing

  • Case is ignored. UNIQUE and COUNTIF treat “Apple”, “apple” and “APPLE” as one value. A case-sensitive count needs a formula built on EXACT, usually with a helper column.
  • Extra spaces count. "Apple" and "Apple " (with a trailing space) are different values. If your count looks too high, run TRIM on the data or clean it with Find & Replace first.
  • Numbers stored as text. A 5 typed as a number and a 5 stored as text can be treated as different values. Convert the column to a single type before counting.
  • Exclude the header. Start your range on the first data row, or the header will be counted as a value.

Bottom line

On current Excel, =COUNTA(UNIQUE(FILTER(A2:A100, A2:A100<>""))) is the formula to use: it’s short, it updates as your data changes, and it skips blanks. If you need to support older versions, use the SUMPRODUCT/COUNTIF formula with the blank-cell fix. For large datasets or counts broken down by category, a Data Model PivotTable with Distinct Count saves you from writing formulas at all. Function availability can change with Excel updates, so check Microsoft’s UNIQUE page if you’re unsure what your version supports.

Frequently asked questions

Why does my unique count come out one higher than expected? +

The column almost certainly contains a blank cell. UNIQUE returns a blank as a value (it shows as 0), and COUNTA counts it. Wrap the range in FILTER(range, range<>"") to drop blanks before counting.

Does Excel treat "Apple" and "apple" as different values? +

No. UNIQUE and COUNTIF are both case-insensitive, so different capitalizations count as one value. If you need a case-sensitive count, you have to build a formula around the EXACT function, usually with a helper column.

Can I count unique values in Excel 2016 or 2019? +

Yes, but not with UNIQUE, which Microsoft lists only for Microsoft 365, Excel 2024 and Excel 2021. Use the SUMPRODUCT and COUNTIF formula, Microsoft's FREQUENCY-based array formula, Advanced Filter plus ROWS, or a PivotTable distinct count on Windows.

What is the difference between unique and distinct values? +

In everyday use, people say unique when they mean distinct: every different value counted once. Strictly, unique can also mean values that appear exactly once. Excel's UNIQUE function handles both, with the exactly_once argument switching between them.

Sources

  1. UNIQUE function - Microsoft Support (support.microsoft.com)
  2. Count unique values among duplicates - Microsoft Support (support.microsoft.com)
  3. Count unique values in a range with COUNTIF - Exceljet (exceljet.net)
  4. How to count unique values in Excel - Ablebits (ablebits.com)
  5. Cannot see Distinct Count in Pivot Table calculation options - Microsoft Q&A (learn.microsoft.com)
About this guide. Researched and drafted with AI assistance from the sources above, then checked against our editorial rules. It reflects what was publicly known on November 16, 2026; details can change, so confirm with the official source before acting on it. How we work →

Our reviews

In-depth reviews from Workflow Picks that go with this topic.

Keep reading