Ninja Excel BlogExcel formulas and functionsCounting in Excel: count numbers, count cells, count everything

Counting in Excel: count numbers, count cells, count everything

calculator

The Count function in Excel is widely useful, especially when we work with large databases. Review its many variations and advantages in this article.

Key information

Before starting, it is very important that you are clear about what you want to say in your Excel spreadsheet so that you can immediately go to the section of this post that will help you achieve your objective. 

Count cells with numbers

This function allows you to count those cells that contain only numbers 

  • Syntax: COUNT(value1;[value2];…)
  • Arguments: 
    • Value1: cell or range of cells to consider for counting. It is a mandatory element. 
    • Value2: Additional cell or range of cells to consider for counting. It's optional. 

Let's try the following table containing makes and models of cars.

Excel table

We will count the number of cells that have numbers: 

count function in excel

Make sure you select the entire range of cells where you want to count. The result is as follows: 

Note that this function counts the cells that contain only numbers. That is, even though “Q3” has a number, having a letter is considered a non-numeric cell. 

result function count in excel

Count non-empty cells (with numbers or letters)

The function WILL COUNT allows you to count those cells that contain only numbers 

  • Syntax: COUNT(value1;[value2];…)
  • Arguments: 
    • Value1: cell or range of cells to consider for counting. It is a mandatory element. 
    • Value2: Additional cell or range of cells to consider for counting. It's optional. 

We will use the same table as before, but notice that now for “Fiat” there is no car model. 

how to count non empty cells

We will now count the number of non-empty cells: 

how to count cells in excel how to count non-empty cells in excel

Note that this command considers cells with any type of content except empty. The result is as follows: 

how to count non-empty cells in excel count cells in excel count cells with text in excel

Count empty cells

The function COUNTBLANK allows you to count those cells that have no content or are empty: 

  • Syntax: COUNTBLANK(range)
  • Arguments: 
    • Range: range of cells to consider for counting blank cells. 

The process is exactly the same as the previous case. We will take the same table whose model for “Fiat” is empty. 

how to count cells in excel count empty cells in excel how to count in excel

We count the empty cells: 

count blank cells excel how to count cells in excel how to count in excel

We see the result below: 

count blank cells excel how to count cells in excel how to count in excel

Have some condition

It is very common to want to count the cells that meet a certain condition. This can be numerical or text. 

The function COUNT YES will allow you to achieve this goal. We will now see a small example, but if you want to know more about this useful function, check the following article.

  • Syntax: COUNTIF(range; criterion)
  • Arguments:
    • range: the selection of cells in which to count
    • criterion: the condition according to which it will be counted

The table of cars with models now also includes a new column with the number of units sold, under the heading “Sales”. 

count cells with some condition in excel how to count cells in excel how to count cells with condition in excel

We will now count the number of models that have sales greater than 100. Note that since we are using a logical criterion (“greater than”), Excel needs it to be in quotes to know how to read it. Then, the formula looks like this: 

count cells with some condition in excel how to count cells in excel how to count cells with condition in excel

And when you press Enter, you get the following result: 

count cells with some condition in excel how to count cells in excel how to count cells with condition in excel

Which means that there are four models that have sales greater than 100. 

Unique values

Many times a data set contains repeated data. This is not necessarily bad, but it can be a way to organize information correctly. For example, the table below again contains information about car brands and their respective models. We see that there are values that are repeated for “Brand”, but that are not repeated for model. That is, there are repeated values for “Brand” but there are no repeated values for the set “Brand” and “Model” (there are not two Chevrolet Corsa). 

count unique values in excel count cells in excel count unique cells in excel

Then, to count the unique values, simply enter the following formula: 

count unique values in excel count cells in excel count unique cells in excel
count unique values in excel count cells in excel count unique cells in excel

The most important thing is to note that you must take the same range twice, since we want to count the elements in “Brand”, considering the “Brand” criterion also to determine if the values are unique. The result is then the following: 

count unique values in excel count cells in excel count unique cells in excel

We see that there are 4 brands considered in the analysis, even though the table contains 7 rows of data. 

Ninja Tip: To count the unique values considering the Brand-Model pair, then you must make a new column that contains both elements. To gather the information into a single column, you can use the CONCATENATE function, and then use that new column as a range to count the unique values. 

Duplicate values

The opposite goal of counting unique values is to count duplicate values. This is naturally accompanied by identifying the number of duplicates according to category. 

Step 1: Copy the “Brand” column to another part of the form and select its content. 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Step 2: Go to the “Data” tab, and in the “Data Tools” section, select the “Remove Duplicates” button. 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Step 3: A new window will appear. We see that it includes the option “My data has headers” and the section is for “Brand”. Simply click on “Accept”.

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

The result is a table that contains only the unique values. 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Step 4: Now we count the duplicate values. We need Excel to count all the times that the name of the Brand column (the duplicate) appears in the “Brand” column (the original). To do this, write down the following formula: 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel
Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Make sure the “range” column where duplicates are searched is set to “$”. The result contains a 2, which is the number of times we found “Chevrolet” in the original “Brand” column. 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Step 5: Drag the formula down. We see that the number of duplicates it has now appears next to each mark. If “Duplicates” is greater than 1, then it is because the value appears more than once. 

Count duplicates in excel how to count duplicates in excel how to count duplicate cells in excel

Carolina is a doctoral student in Economics at Yale University and a Business Engineer at the Catholic University of Chile. She works with databases doing applied research on education, gender and labor market issues.

white ninja excel logo

The leading Excel training platform for companies.

Company

Copyright © 2024 Ninja Excel.

English