How To Count Unique Values in Excel [2024 Guide]

If youโ€™re working with larger data sets, youโ€™ll commonly encounter duplicates in your spreadsheets. This is the main reason youโ€™ll have to count unique values in Excel.

Luckily, Excel has various capabilities to help you handle even the biggest data dumps.

As such, several methods exist to count the number of unique values in Excel. This guide will cover them all in detail with easy-to-understand instructions and screenshots.

What Are Distinct and Unique Values in Excel?

What are the unique values in Excel? These values only appear once in a data set. For example, consider the dataset: โ€œ1, 2, 2, 3.โ€ In this data, 1 and 3 would be the unique values.

Whereas distinct values in a list are unique from each other. For example, in the data set โ€œ1, 2, 2, 3.โ€ The distinct values here would be โ€œ1, 2, 3.โ€

Count unique values in Excelโ€”Example spreadsheet

 

Related: Count Unique Values in Google Sheets

Using the COUNTIF Formula to Count Unique Values in Excel

In addition to utilizing the SUM function, the IF function, and COUNTIF formulas can be used to count unique Excel values in any given range.

When using COUNTIF, a โ€œcount unique values Excel formulaโ€ would look something like this:

=SUM(IF( COUNTIF( range, range) = 1, 1, 0)) 

To include Excel count unique values in a column:

  1. In your spreadsheet, determine the range that to discover unique values within. Here, weโ€™ll count unique values within the names column.
Example worksheet for counting unique values with COUNTIF

 

  1. Select a new cell and input the equals sign (=), followed by the SUM function, IF function, and COUNTIF function:
    =SUM(IF(COUNTIF(
  2. Select the range by highlighting the cells or inputting it manually. Remember to press Shift + Ctrl + Enter on your keyboard for Excel to place the curly brackets automatically.

The formula should look like this:

{=SUM(IF(COUNTIF(B3:B13, B3:B13) = 1, 1, 0))}
  1. Once youโ€™ve entered the formula, press โ€œEnter.โ€ The amount of Excel unique values inside the range will be displayed. In our case, there are four unique values.
Results of using the countif function to count unique values
Important: Most of the formulas used in this guide are array Excel formulas. This means youโ€™ll need to press Shift + Ctrl + Enter after youโ€™re done inserting the formula. This will allow Excel automatically places curly brackets {} where they should be.

Count Unique Number Values Only

To count only numbers while ignoring text, add the ISNUMBER function in the original array formula.

The new array formula will be:

=SUM( IF( ISNUMBER( range )*COUNTIF( range, range) = 1, 1, 0))

The steps are also similar to how you use the ISTEXT function.

  1. Determine the range of unique number values youโ€™d like to count. For example, letโ€™s say we want to count the unique number values in the values list from our sample sheet.
Example worksheet for counting unique values with COUNTIF

 

  1. After determining the range, select a new cell and input the new array formula with the ISNUMBER function added.

In our case, the formula will be:

=SUM(IF(ISNUMBER(B3:B13),1/COUNTIF(B3:B13, B3:B13),""))

Press Shift + Ctrl + Enter after inputting the new formula in a new cell.

  1. The formula will count and display the unique number values (in the specified range). In our case, the unique number value is 2.
Results for the number of unique number values in the specified range

 

Because Excel also considers dates and times as serial number values, they can be counted using the same formula.

How To Count Text Values Only in Excel

When the dataset contains a mixture of numeric and text, but you only wish to tally the text values in the list, then you should use ISTEXT alongside your formula.

The new syntax would be:

=SUM(IF(ISTEXT(range)*COUNTIF(range,range) = 1, 1, 0)) 

If we use the above syntax in a spreadsheet to count unique values in Excel with multiple criteria:

  1. Determine the range of unique text values to count. Highlight it.
  2. Select a new cell and input the new array formula with the ISTEXT function added.

In our case, the formula will be:

=SUM(IF(ISTEXT(B3:B13)*COUNTIF(B3:B13,B3:B13) = 1, 1, 0))
  1. Press Shift + Ctrl + Enter after inputting the new formula in a new cell to make it an array formula.
  2. The formula will count and display unique values within the specified range.
Unique text values in specified Excel range

Using the Advanced Filter Tool to Count Unique Values in Excel

Another way to find the number of unique values in Excel is by using the Advanced filter tool. Unlike Google Sheets, this filter tool can extract data from a table. This is an easy and handy tool for counting unique values in Excel.

  1. Highlight the range of cells containing the desired data.
Example worksheet for counting unique values with COUNTIF

 

  1. Navigate to the โ€œDataโ€ tab in the Excel ribbon.
Navigate to the Data tab in the Excel ribbon

 

  1. Once in the data tab, click the โ€œAdvancedโ€ button in the โ€œSort & Filterโ€ section.
Click on Advanced in Excel Sort & Filter section

 

  1. After clicking Advanced, a dialogue box will appear. Select โ€œCopy to another location.โ€
Select the Copy to another location option.

 

  1. Specify the destination to copy the unrepeated values provided for you in the dialogue box.
Specify a destination for unique values exc

 

  1. Check โ€œUnique records only.โ€
Check the unique records only box in Excel

 

  1. Click on โ€œOK.โ€ Excel will automatically copy the highlighted values and paste them into the range of cells you specified (in the Copy to field).
Copy the unique values and paste in Excel cells

 

  1. After the unrepeated values are copied, you can utilize the COUNT or COUNTA function to tally them.

For example, you might use:

=COUNTA(H2:H9) 

Place this formula in an empty cell to count the specified cells. In our sheet, the amount of unique values in our example is 8.

Use the COUNT or COUNTA function count unique values

How To Count Distinct Values in Excel

Excel offers several tools for counting distinct values efficiently. These are the tools, techniques, and formulas to do so.

1. Using COUNTIF to Count Distinct Values in Excel

For this method, we use the SUM function and the COUNTIF function to tally the distinct values.

The formula to tally the distinct values will follow the following syntax:

=SUM( 1/ COUNTIF( range, range)) 

Just like with finding unique values, remember to use Shift + Ctrl + Enter to make an array.

Here are the steps to using the formula:

  1. Determine the range in which you wish to count distinct cells from. Let’s use the spreadsheet below as an example and try to add up the number of distinct values in the names list.
Example worksheet for counting unique values with COUNTIF

 

  1. After finding the range, insert the formula in an empty cell and Press Shift + Ctrl + Enter on your keyboard.

Our formula will look like this:

{=SUM( 1/ COUNTIF(B3:B13, B3:B13))}
  1. The formula will then count the number of distinct values in the specified range of cells and display the number in the cell where the formula was inserted. Our sample came out as 7.
The formula will then count the number of distinct values in the specified range of cells

 

That is how you count the number of unique values in a column in Excel using the COUNTIF function. However, there is another alternative. Instead of using the SUM function, you can utilize the SUMPRODUCT function and still get the same results.

Here is how you use the SUMPRODUCT function together with the COUNTIF function instead of the SUM function.

  1. Determine the range you want to add up distinct values only in your worksheet. Let’s use the same worksheet as the one used above as an example and try to add up the distinct values in the names list using the SUMPRODUCT function.
Example worksheet for counting unique values with COUNTIF

 

  1. The next step is to select an empty cell to place the new array formula, which will follow this syntax:
=SUMPRODUCT( 1/ COUNTIF(range, range)

In our example, the formula will be as shown below:

{=SUMPRODUCT( 1/ COUNTIF(B3:B13, B3:B13))}

When using this method, you do not have to Press Shift + Ctrl + Enter after inputting the formula. You can press โ€œEnter.โ€

  1. The number of distinct values in the specified range of cells will be displayed in the cell where you implemented the formula. You can see that the amount of distinct values in our names list is 7, just like when we used the SUM function together with the COUNTIF function.
Using the SUMPRODUCT function to count unique values in Excel

2. How to Count Distinct Number Values Only in Excel

If you want to sum up the distinct number values only in a list containing both text and number values, you have to use ISNUMBER instead of ISTEXT.

This is the syntax for the formula:

=SUM(IF(ISNUMBER(range), 1/COUNTIF(range, range), โ€œโ€))

Here is how you apply it:

  1. Determine the range of cells you wish to count distinct number values from
  2. Select an empty cell and insert the formula. Press Shift + Ctrl + Enter after inputting the formula.

Here is what we see in the example:

=SUM(IF(ISNUMBER(B3:B13), 1/COUNTIF(B3:B13, B3:B13), ""))
  1. The formula will then display the number of distinct text values.
    Results for counting distinct number values in Excel

3. How To Count Distinct Text Values Only in Excel

Your worksheet may have a mixture of text values and number values in a list, and you may want to count only the distinct text values. This is another situation you may encounter when trying to add distinct values to a dataset.

To accomplish this, we use the following formula format:

=SUM(IF(ISTEXT(range), 1/COUNTIF(range, range), โ€œโ€))

I’m sure you noticed that the formula is not very different, and that is because we embedded the ISTEXT function in the formula to add distinct values.

Here is how you apply the formula:

  1. Determine the range in which you wish to count distinct text values only.
Example worksheet for counting unique values with COUNTIF

 

  1. Select an empty cell and input the formula. Press Shift + Ctrl + Enter after inputting the formula.

Hereโ€™s what we used in the example

=SUM(IF(ISTEXT(B3:B13), 1/COUNTIF(B3:B13, B3:B13), ""))
  1. The formula will count only the distinct text values and show the number in the cell you placed the formula in.
Results for counting distinct text values in Excel

 

Related: The Best Microsoft Excel Courses on the Web

4. How To Count Distinct Values While Ignoring Empty or Blank Cells in Excel

The list or range of cells you add distinct values to may have blank spaces. That may interfere with the methods mentioned above.

In this example, we use a similar formula to our first distinct values example. However, we also use the IF function.

To add up the distinct values while ignoring empty cells in Excel:

=SUM(IF(range<>โ€โ€,1/COUNTIF(range, range), 0))

Since this is an array Excel formula, remember to press Shift + Ctrl + Enter after including the formula:

  1. Determine the range to count distinct cells that have blank spaces.
Example worksheet for counting unique values with COUNTIF

 

  1. Select an empty cell and insert the array formula containing the IF function:
{=SUM(IF(B3:B13<>"",1/COUNTIF(B3:B13, B3:B13), 0))}
  1. Press Shift + Ctrl + Enter after inputting the formula (to make it an array formula).
  2. The number of distinct cells will be displayed in the cell where youโ€™ve implemented the formula.
Counting unique values while ignoring blank cells

Final Thoughts

As you can see, there are many ways to count unique values in Excel (and add distinct values, too). Generally speaking, these formula solutions are ideal as they provide results directly into your spreadsheet.

Looking to skip the learning curve and start using some powerful pre-made spreadsheets? Check out our premium template library. When you use the code โ€œSSP,โ€ youโ€™ll save 50% at checkout!

Get Premium Templates

Related:

 

Most Popular Posts

Related Posts

Thanks for visiting! We’re happy to answer your spreadsheet questions. We specialize in formulas for Google Sheets, our own spreadsheet templates, and time-saving Excel tips.

Note that we’re supported by our audience. When you purchase through links on our site, we may earn commission at no extra cost to you.

Like what we do? Share this article!