Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
Register  \/ 


Count unique values in a range in Excel

This tutorial explains how to count only the unique values among duplicates in a list in Excel with specified formulas.

How to count unique values in one column in Excel?

Supposing you have a products table as the below screenshot shown, to count only the unique values in the Product column, you can apply one of the below formulas.

Generic Formulas




Range: The range of cells you want to count only the unique values;
Range.firstcell: The first cell of the range.

How to use these formulas?

1. Select a blank cell to output the result.

2. Enter one of the below formulas into the selected cell and press the Enter key.




1) In these formulas, D3:D16 is the range of cells you want to count only unique values, and D3 is the first cell of the range. You can change them as you need.
2) If empty cells existing in the specified range, the first formula will return an #N/A error, and the second formula will return a #DIV/0 error.

Explanation of formulas


  • MATCH(D3:D16,D3:D16,0): The MATCH function gets the position of each item in range D3:D16, if the values appear more than once in the data range, it will return the same position to get the array like this {1;2;3;2;1;1;3;2;1;1;1;2;3;2}.
  • ROW(D3:D16)-ROW(D3)+1: Here the ROW function returns the row number of reference D3:D16 and D3, and you will get {3;4;5;6;7;8;9;10;11;12;13;14;15;16}-{3}+1.
  • Each number in the array subtracts number 3 then adds 1 and finally returns {1;2;3;4;5;6;7;8;9;10;11;12;13;14}.
  • FREQUENCY({1;2;3;2;1;1;3;2;1;1;1;2;3;2},{1;2;3;4;5;6;7;8;9;10;11;12;13;14}): The frequency function calculates how often each number occurs in the data array and returns an array of numbers like this {6;5;3;0;0;0;0;0;0;0;0;0;0;0}.
  • SUMPRODUCT(--{6;5;3;0;0;0;0;0;0;0;0;0;0;0}>0):
{6;5;3;0;0;0;0;0;0;0;0;0;0;0}>0: Each number in the array compares with 0, and returns TRUE if greater than 0, otherwise, returns FALSE. And you will get a TRUE FALSE array like this {TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE};
--{TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}: These two minus signs convert “TRUE” into 1 and “FALSE” into 0. Here you will get a new array as{1;1;1;0;0;0;0;0;0;0;0;0;0;0}.
SUMPRODUCT({1;1;1;0;0;0;0;0;0;0;0;0;0;0}): The SUMPRODUCT function sums all numbers in the array and returns the final result as 3.


  • COUNTIF(D3:D16,D3:D16): The COUNTIF function counts how often each value occurs in the range D3:D16, using all the same values as criteria. It returns an array like this {6;5;3;5;6;6;3;5;6;6;6;5;3;5}, which mean that Laptop appears 6 times, Projector appears 5 times and Display appears 3 times.
  • 1/{6;5;3;5;6;6;3;5;6;6;6;5;3;5}: Each number in the array is divided by 1, and returns a new array as {0.166666666666667;0.2;0.333333333333333;0.2;0.166666666666667;0.166666666666667;0.2;
  • SUMPRODUCT({0.166666666666667;0.2;0.333333333333333;0.2;0.166666666666667;0.166666666666667;
    : Then SUMPRODUCT function sums all numbers in the array and returns the final result as 3.

Related functions

Excel SUMPRODUCT function
The Excel SUMPRODUCT function can be used to multiply two or more columns or arrays together, and then get the sum of products.

Excel FREQUENCY function
The Excel FREQUENCY function calculates how often values occur within a range of values, and then returns a vertical array of numbers.

Excel MATCH function
The Excel MATCH function searches for a specific value in a range of cells, and returns the relative position of this value.

Excel ROW function
The Excel ROW function returns the row number of a reference.

Excel COUNTIF function
The Excel COUNTIF function is used to count the number of cells that meet a criterion.

Related formulas

Count Number Of Visible Rows In A Filtered List
This tutorial explains how to count number of visible rows in a filtered list in Excel with the SUBTOTAL function.

Count unique values with criteria
This step-by-step guide helps to count only unique values based on a specified criteria in another column

Count visible rows with criteria
This tutorial provides detailed steps to help you count visible rows with criteria.

Use COUNTIF on a non-contiguous range
This step-by-step guide demonstrates how to use the countif function on a non-contiguous range in Excel.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.