Counting the number of unique values

Excel 365 2016 2013 2007 2003
You can easily count the number of unique values of the range using a simple formula.

For example, you want to count the number of unique values of the range:

Data in Excel 2010

You can enter the next formula to the range D2:D12:

= SUM (1 / COUNTIF ($A$2:$A$12, $A$2:$A$12))

Summarize amount from a range D2:D12:

Counting the number of unique values in Excel 2010

This formula has a serious limitation: If the range contains any blank cells, it returns an error. The following formula solves this problem:

= SUM (IF (COUNTIF ($A$2:$A$12, $A$2:$A$12) = 0, "", 1 / COUNTIF ($A$2:$A$12, $A$2:$A$12)))

If you have any questions or suggestions, please feel free to ask OfficeToolTips team.

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information you’ve provided to them or they’ve collected from your use of their services.

Learn more