Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
The COUNT function counts the number of cells that contain numbers, and counts numbers within the list of arguments. Use the COUNT function to get the number of entries in a number field that is in a range or array of numbers. For example, you can enter the following formula to count the numbers in the range A1:A20: =COUNT(A1:A20). In this example, if five of the cells in the range contain numbers, the result is 5.
Syntax
COUNT(value1, [value2], …)
The COUNT function syntax has the following arguments:
-
value1 Required. The first item, cell reference, or range within which you want to count numbers.
-
value2, … Optional. Up to 255 additional items, cell references, or ranges within which you want to count numbers.
Note: The arguments can contain or refer to a variety of different types of data, but only numbers are counted.
Remarks
-
Arguments that are numbers, dates, or a text representation of numbers (for example, a number enclosed in quotation marks, such as «1») are counted.
-
Logical values and text representations of numbers that you type directly into the list of arguments are counted.
-
Arguments that are error values or text that cannot be translated into numbers are not counted.
-
If an argument is an array or reference, only numbers in that array or reference are counted. Empty cells, logical values, text, or error values in the array or reference are not counted.
-
If you want to count logical values, text, or error values, use the COUNTA function.
-
If you want to count only numbers that meet certain criteria, use the COUNTIF function or the COUNTIFS function.
Example
Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.
Data |
||
12/8/08 |
||
19 |
||
22.24 |
||
TRUE |
||
#DIV/0! |
||
Formula |
Description |
Result |
=COUNT(A2:A7) |
Counts the number of cells that contain numbers in cells A2 through A7. |
3 |
=COUNT(A5:A7) |
Counts the number of cells that contain numbers in cells A5 through A7. |
2 |
=COUNT(A2:A7,2) |
Counts the number of cells that contain numbers in cells A2 through A7, and the value 2 |
4 |
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Counting is an integral part of data analysis, whether you are tallying the head count of a department in your organization or the number of units that were sold quarter-by-quarter. Excel provides multiple techniques that you can use to count cells, rows, or columns of data. To help you make the best choice, this article provides a comprehensive summary of methods, a downloadable workbook with interactive examples, and links to related topics for further understanding.
Download our examples
You can download an example workbook that gives examples to supplement the information in this article. Most sections in this article will refer to the appropriate worksheet within the example workbook that provides examples and more information.
Download examples to count values in a spreadsheet
In this article
-
Simple counting
-
Use AutoSum
-
Add a Subtotal row
-
Count cells in a list or Excel table column by using the SUBTOTAL function
-
-
Counting based on one or more conditions
-
Video: Use the COUNT, COUNTIF, and COUNTA functions
-
Count cells in a range by using the COUNT function
-
Count cells in a range based on a single condition by using the COUNTIF function
-
Count cells in a column based on single or multiple conditions by using the DCOUNT function
-
Count cells in a range based on multiple conditions by using the COUNTIFS function
-
Count based on criteria by using the COUNT and IF functions together
-
Count how often multiple text or number values occur by using the SUM and IF functions together
-
Count cells in a column or row in a PivotTable
-
-
Counting when your data contains blank values
-
Count nonblank cells in a range by using the COUNTA function
-
Count nonblank cells in a list with specific conditions by using the DCOUNTA function
-
Count blank cells in a contiguous range by using the COUNTBLANK function
-
Count blank cells in a non-contiguous range by using a combination of SUM and IF functions
-
-
Counting unique occurrences of values
-
Count the number of unique values in a list column by using Advanced Filter
-
Count the number of unique values in a range that meet one or more conditions by using IF, SUM, FREQUENCY, MATCH, and LEN functions
-
-
Special cases (count all cells, count words)
-
Count the total number of cells in a range by using ROWS and COLUMNS functions
-
Count words in a range by using a combination of SUM, IF, LEN, TRIM, and SUBSTITUTE functions
-
-
Displaying calculations and counts on the status bar
Simple counting
You can count the number of values in a range or table by using a simple formula, clicking a button, or by using a worksheet function.
Excel can also display the count of the number of selected cells on the Excel status bar. See the video demo that follows for a quick look at using the status bar. Also, see the section Displaying calculations and counts on the status bar for more information. You can refer to the values shown on the status bar when you want a quick glance at your data and don’t have time to enter formulas.
Video: Count cells by using the Excel status bar
Watch the following video to learn how to view count on the status bar.
Use AutoSum
Use AutoSum by selecting a range of cells that contains at least one numeric value. Then on the Formulas tab, click AutoSum > Count Numbers.
Excel returns the count of the numeric values in the range in a cell adjacent to the range you selected. Generally, this result is displayed in a cell to the right for a horizontal range or in a cell below for a vertical range.
Top of Page
Add a Subtotal row
You can add a subtotal row to your Excel data. Click anywhere inside your data, and then click Data > Subtotal.
Note: The Subtotal option will only work on normal Excel data, and not Excel tables, PivotTables, or PivotCharts.
Also, refer to the following articles:
-
Outline (group) data in a worksheet
-
Insert subtotals in a list of data in a worksheet
Top of Page
Count cells in a list or Excel table column by using the SUBTOTAL function
Use the SUBTOTAL function to count the number of values in an Excel table or range of cells. If the table or range contains hidden cells, you can use SUBTOTAL to include or exclude those hidden cells, and this is the biggest difference between SUM and SUBTOTAL functions.
The SUBTOTAL syntax goes like this:
SUBTOTAL(function_num,ref1,[ref2],…)
To include hidden values in your range, you should set the function_num argument to 2.
To exclude hidden values in your range, set the function_num argument to 102.
Top of Page
Counting based on one or more conditions
You can count the number of cells in a range that meet conditions (also known as criteria) that you specify by using a number of worksheet functions.
Video: Use the COUNT, COUNTIF, and COUNTA functions
Watch the following video to see how to use the COUNT function and how to use the COUNTIF and COUNTA functions to count only the cells that meet conditions you specify.
Top of Page
Count cells in a range by using the COUNT function
Use the COUNT function in a formula to count the number of numeric values in a range.
In the above example, A2, A3, and A6 are the only cells that contains numeric values in the range, hence the output is 3.
Note: A7 is a time value, but it contains text (a.m.), hence COUNT does not consider it a numerical value. If you were to remove a.m. from the cell, COUNT will consider A7 as a numerical value, and change the output to 4.
Top of Page
Count cells in a range based on a single condition by using the COUNTIF function
Use the COUNTIF function function to count how many times a particular value appears in a range of cells.
Top of Page
Count cells in a column based on single or multiple conditions by using the DCOUNT function
DCOUNT function counts the cells that contain numbers in a field (column) of records in a list or database that match conditions that you specify.
In the following example, you want to find the count of the months including or later than March 2016 that had more than 400 units sold. The first table in the worksheet, from A1 to B7, contains the sales data.
DCOUNT uses conditions to determine where the values should be returned from. Conditions are typically entered in cells in the worksheet itself, and you then refer to these cells in the criteria argument. In this example, cells A10 and B10 contain two conditions—one that specifies that the return value must be greater than 400, and the other that specifies that the ending month should be equal to or greater than March 31st, 2016.
You should use the following syntax:
=DCOUNT(A1:B7,»Month ending»,A9:B10)
DCOUNT checks the data in the range A1 through B7, applies the conditions specified in A10 and B10, and returns 2, the total number of rows that satisfy both conditions (rows 5 and 7).
Top of Page
Count cells in a range based on multiple conditions by using the COUNTIFS function
The COUNTIFS function is similar to the COUNTIF function with one important exception: COUNTIFS lets you apply criteria to cells across multiple ranges and counts the number of times all criteria are met. You can use up to 127 range/criteria pairs with COUNTIFS.
The syntax for COUNTIFS is:
COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2],…)
See the following example:
Top of Page
Count based on criteria by using the COUNT and IF functions together
Let’s say you need to determine how many salespeople sold a particular item in a certain region or you want to know how many sales over a certain value were made by a particular salesperson. You can use the IF and COUNT functions together; that is, you first use the IF function to test a condition and then, only if the result of the IF function is True, you use the COUNT function to count cells.
Notes:
-
The formulas in this example must be entered as array formulas. If you have opened this workbook in Excel for Windows or Excel 2016 for Mac and want to change the formula or create a similar formula, press F2, and then press Ctrl+Shift+Enter to make the formula return the results you expect. In earlier versions of Excel for Mac, use +Shift+Enter.
-
For the example formulas to work, the second argument for the IF function must be a number.
Top of Page
Count how often multiple text or number values occur by using the SUM and IF functions together
In the examples that follow, we use the IF and SUM functions together. The IF function first tests the values in some cells and then, if the result of the test is True, SUM totals those values that pass the test.
Example 1
The above function says if C2:C7 contains the values Buchanan and Dodsworth, then the SUM function should display the sum of records where the condition is met. The formula finds three records for Buchanan and one for Dodsworth in the given range, and displays 4.
Example 2
The above function says if D2:D7 contains values lesser than $9000 or greater than $19,000, then SUM should display the sum of all those records where the condition is met. The formula finds two records D3 and D5 with values lesser than $9000, and then D4 and D6 with values greater than $19,000, and displays 4.
Example 3
The above function says if D2:D7 has invoices for Buchanan for less than $9000, then SUM should display the sum of records where the condition is met. The formula finds that C6 meets the condition, and displays 1.
Important: The formulas in this example must be entered as array formulas. That means you press F2 and then press Ctrl+Shift+Enter. In earlier versions of Excel for Mac use +Shift+Enter.
See the following Knowledge Base articles for additional tips:
-
XL: Using SUM(IF()) As an Array Function Instead of COUNTIF() with AND
-
XL: How to Count the Occurrences of a Number or Text in a Range
Top of Page
Count cells in a column or row in a PivotTable
A PivotTable summarizes your data and helps you analyze and drill down into your data by letting you choose the categories on which you want to view your data.
You can quickly create a PivotTable by selecting a cell in a range of data or Excel table and then, on the Insert tab, in the Tables group, clicking PivotTable.
Let’s look at a sample scenario of a Sales spreadsheet, where you can count how many sales values are there for Golf and Tennis for specific quarters.
Note: For an interactive experience, you can run these steps on the sample data provided in the PivotTable sheet in the downloadable workbook.
-
Enter the following data in an Excel spreadsheet.
-
Select A2:C8
-
Click Insert > PivotTable.
-
In the Create PivotTable dialog box, click Select a table or range, then click New Worksheet, and then click OK.
An empty PivotTable is created in a new sheet.
-
In the PivotTable Fields pane, do the following:
-
Drag Sport to the Rows area.
-
Drag Quarter to the Columns area.
-
Drag Sales to the Values area.
-
Repeat step c.
The field name displays as SumofSales2 in both the PivotTable and the Values area.
At this point, the PivotTable Fields pane looks like this:
-
In the Values area, click the dropdown next to SumofSales2 and select Value Field Settings.
-
In the Value Field Settings dialog box, do the following:
-
In the Summarize value field by section, select Count.
-
In the Custom Name field, modify the name to Count.
-
Click OK.
-
The PivotTable displays the count of records for Golf and Tennis in Quarter 3 and Quarter 4, along with the sales figures.
-
Top of Page
Counting when your data contains blank values
You can count cells that either contain data or are blank by using worksheet functions.
Count nonblank cells in a range by using the COUNTA function
Use the COUNTA function function to count only cells in a range that contain values.
When you count cells, sometimes you want to ignore any blank cells because only cells with values are meaningful to you. For example, you want to count the total number of salespeople who made a sale (column D).
COUNTA ignores the blank values in D3, D4, D8, and D11, and counts only the cells containing values in column D. The function finds six cells in column D containing values and displays 6 as the output.
Top of Page
Count nonblank cells in a list with specific conditions by using the DCOUNTA function
Use the DCOUNTA function to count nonblank cells in a column of records in a list or database that match conditions that you specify.
The following example uses the DCOUNTA function to count the number of records in the database that is contained in the range A1:B7 that meet the conditions specified in the criteria range A9:B10. Those conditions are that the Product ID value must be greater than or equal to 2000 and the Ratings value must be greater than or equal to 50.
DCOUNTA finds two rows that meet the conditions- rows 2 and 4, and displays the value 2 as the output.
Top of Page
Count blank cells in a contiguous range by using the COUNTBLANK function
Use the COUNTBLANK function function to return the number of blank cells in a contiguous range (cells are contiguous if they are all connected in an unbroken sequence). If a cell contains a formula that returns empty text («»), that cell is counted.
When you count cells, there may be times when you want to include blank cells because they are meaningful to you. In the following example of a grocery sales spreadsheet. suppose you want to find out how many cells don’t have the sales figures mentioned.
Note: The COUNTBLANK worksheet function provides the most convenient method for determining the number of blank cells in a range, but it doesn’t work very well when the cells of interest are in a closed workbook or when they do not form a contiguous range. The Knowledge Base article XL: When to Use SUM(IF()) instead of CountBlank() shows you how to use a SUM(IF()) array formula in those cases.
Top of Page
Count blank cells in a non-contiguous range by using a combination of SUM and IF functions
Use a combination of the SUM function and the IF function. In general, you do this by using the IF function in an array formula to determine whether each referenced cell contains a value, and then summing the number of FALSE values returned by the formula.
See a few examples of SUM and IF function combinations in an earlier section Count how often multiple text or number values occur by using the SUM and IF functions together in this topic.
Top of Page
Counting unique occurrences of values
You can count unique values in a range by using a PivotTable, COUNTIF function, SUM and IF functions together, or the Advanced Filter dialog box.
Count the number of unique values in a list column by using Advanced Filter
Use the Advanced Filter dialog box to find the unique values in a column of data. You can either filter the values in place or you can extract and paste them to a new location. Then you can use the ROWS function to count the number of items in the new range.
To use Advanced Filter, click the Data tab, and in the Sort & Filter group, click Advanced.
The following figure shows how you use the Advanced Filter to copy only the unique records to a new location on the worksheet.
In the following figure, column E contains the values that were copied from the range in column D.
Notes:
-
If you filter your data in place, values are not deleted from your worksheet — one or more rows might be hidden. Click Clear in the Sort & Filter group on the Data tab to display those values again.
-
If you only want to see the number of unique values at a quick glance, select the data after you have used the Advanced Filter (either the filtered or the copied data) and then look at the status bar. The Count value on the status bar should equal the number of unique values.
For more information, see Filter by using advanced criteria
Top of Page
Count the number of unique values in a range that meet one or more conditions by using IF, SUM, FREQUENCY, MATCH, and LEN functions
Use various combinations of the IF, SUM, FREQUENCY, MATCH, and LEN functions.
For more information and examples, see the section «Count the number of unique values by using functions» in the article Count unique values among duplicates.
Top of Page
Special cases (count all cells, count words)
You can count the number of cells or the number of words in a range by using various combinations of worksheet functions.
Count the total number of cells in a range by using ROWS and COLUMNS functions
Suppose you want to determine the size of a large worksheet to decide whether to use manual or automatic calculation in your workbook. To count all the cells in a range, use a formula that multiplies the return values using the ROWS and COLUMNS functions. See the following image for an example:
Top of Page
Count words in a range by using a combination of SUM, IF, LEN, TRIM, and SUBSTITUTE functions
You can use a combination of the SUM, IF, LEN, TRIM, and SUBSTITUTE functions in an array formula. The following example shows the result of using a nested formula to find the number of words in a range of 7 cells (3 of which are empty). Some of the cells contain leading or trailing spaces — the TRIM and SUBSTITUTE functions remove these extra spaces before any counting occurs. See the following example:
Now, for the above formula to work correctly, you have to make this an array formula, otherwise the formula returns the #VALUE! error. To do that, click on the cell that has the formula, and then in the Formula bar, press Ctrl + Shift + Enter. Excel adds a curly bracket at the beginning and the end of the formula, thus making it an array formula.
For more information on array formulas, see Overview of formulas in Excel and Create an array formula.
Top of Page
Displaying calculations and counts on the status bar
When one or more cells are selected, information about the data in those cells is displayed on the Excel status bar. For example, if four cells on your worksheet are selected, and they contain the values 2, 3, a text string (such as «cloud»), and 4, all of the following values can be displayed on the status bar at the same time: Average, Count, Numerical Count, Min, Max, and Sum. Right-click the status bar to show or hide any or all of these values. These values are shown in the illustration that follows.
Top of Page
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers community.
What Is COUNT In Excel?
The COUNT function in Excel counts the number of cells containing numerical values within the given range. It always returns an integer value.
The COUNT in Excel is an inbuilt statistical function, so we can insert the formula from the “Function Library” or enter it directly in the worksheet.
For example, to count a range of cells that contain a date before April 1, 2021, the formula used is “=COUNT(“Cell Range”, “<”&DATE (2021,4,1))”. The date is entered by using the DATE functionThe date function in excel is a date and time function representing the number provided as arguments in a date and time code. The result displayed is in date format, but the arguments are supplied as integers.read more.
Table of contents
- What Is COUNT In Excel?
- Syntax Of COUNT Excel Formula
- How To Use COUNT Function In Excel?
- Examples
- The Characteristics Of The COUNT Function
- Important Things To Note
- Frequently Asked Questions (FAQs)
- COUNT Function In Excel Video
- Download Template
- Recommended Articles
- In a given dataset, the COUNT function in Excel returns the count of the numeric values.
- It counts only the numbers and not the logical values, empty cells, text, or error values when the argument seems to be an array or reference.
- The usage of the COUNT and VBA (VBA Excel COUNT) functions are the same in Excel.
- The COUNTA function is a further extension of the COUNT function. It counts logical values, text, or error values. The COUNTIF function (another extension of the COUNT function) counts the numbers that meet a specified criterion.
Syntax Of COUNT Excel Formula
The syntax of the COUNT Excel formula is,
The arguments of the COUNT Excel formula are,
- value1, [value2], …, [value n]: It is a mandatory argument. It can range up to 255 values. The value can be a cell referenceCell reference in excel is referring the other cells to a cell to use its values or properties. For instance, if we have data in cell A2 and want to use that in cell A1, use =A2 in cell A1, and this will copy the A2 value in A1.read more or a range of values. It is a collection of worksheet cells containing a variety of data, out of which only the cells containing numbers are counted.
How To Use COUNT Function In Excel?
We can use the COUNT Excel function in 2 ways, namely:
- Access from the Excel ribbon.
- Enter in the worksheet manually.
Method #1 – Access from the Excel ribbon
Choose an empty cell for the result → select the “Formulas” tab → go to the “Function Library” group → click the “More Functions” option drop-down → click the “Statistical” option right arrow → select the “COUNT” function, as shown below.
The “Function Arguments” windowappears. Enter the arguments in the “Value1”, “Value2”, etc. fields, and click “OK”, as shown below.
Method #2 – Enter in the worksheet manually
- Select an empty cell for the output.
- Type =COUNT( in the selected cell. [Alternatively, type =C or =COU and double-click the COUNT function from the list of suggestions shown by Excel.
- Enter the argument as cell value or cell reference and close the brackets.
- Press the “Enter” key.
Basic Example – Count Numbers in the Given Range
Let us look at an example to apply the COUNT function to Count Numbers in the Given Range. (shown in the table below).
Select cell B10, enter the formula =COUNT(B3:B8), and press “Enter”.
The output is shown above. The range B3:B8 contains only three numeric values. Hence, the COUNT function returns 3.
Examples
We will consider some scenarios using COUNT Function in Excel examples. Each example covers a different case, implemented using the COUNT function.
Example #1 – Count Non-empty Cells
Let us apply the COUNTA functionThe COUNTA function is an inbuilt statistical excel function that counts the number of non-blank cells (not empty) in a cell range or the cell reference. For example, cells A1 and A3 contain values but, cell A2 is empty. The formula “=COUNTA(A1,A2,A3)” returns 2.
read more to the range of cells A1:A5 provided in the below table to find the count of the number of cells that are not empty.
Select cell B1, enter the formula =COUNTA(A1:A5), and press “Enter”.
The output is shown above. The COUNTA function counts the number of cells from A1 through A5 that contain some data. It returns the value as 4, as cells A1, A2, A3, and A4 are not empty, and only cell A5 is empty.
Example #2 – Count the Number of Valid Dates
Let us apply the COUNT function to count the number of valid dates to the range of cells C3:C8 (shown in the table below).
Select cell C10, enter the formula =COUNT(C3:C8), and press “Enter”.
The output is shown above. The range contains dates in different formats. Out of this, only two dates are valid. Hence, the formula returns 2.
Example #3 – Multiple Parameters
Let us apply the COUNT formula to the range of excel cells C3:C7 (provided in the table below) along with another parameter that is hard-coded with a value of 5.
Select cell C11, enter the formula =COUNTA(C3:C7,5), and press “Enter”.
The output is shown above. The number of cells (C3 through C7) with valid numeric values or dates is 2, plus 1 for the number 5. Hence the COUNT formula returns the result as 3 (cells C5, C6, and the number 5). Note that the date in cell C7 is invalid, and so is not taken into account in the given results.
Example #4 – Invalid Numbers
Let us apply the COUNT formula to the range of values B6:B8 (shown in the table below) containing invalid numbers.
Select cell B12, enter the formula =COUNTA(B6:B8), and press “Enter”.
The output is shown above. The range does not have any valid number. Hence, the result returned by the formula is 0, indicated in cell B12.
Example #5 – Empty Range
Let us apply the COUNT function to the range of values in cells D3:D5, which is an empty range.
Select cell D10, enter the formula =COUNTA(D3:D5), and press “Enter”.
The output is shown above. The given range does not have any numbers, and it is empty. Hence, the result returned by the formula is 0, indicated in cell D10.
The Characteristics Of The COUNT Function
The features of the COUNT Excel function are listed as follows:
- It counts the list of parameters containing the logical values and text representations.
- It does not count the error values or text which cannot be converted into numbers.
- It counts only the numbers and not the logical values, empty cells, text, or error values when the argument seems to be an array or reference.
- A further extension to the COUNT function is the COUNTA function. It counts logical values, text, or error values.
- Another extension of the COUNT function is the COUNTIF function, which counts the numbers that meet a specified criterion.
Important Things To Note
- Since the COUNT function has other related functions such as COUNTA, COUNTIF, COUNTBLANK, etc., we must ensure we enter the right function name to avoid getting a “#NAME?” error.
- In a selected cell range, the function ignores the blank cells, non-numeric cells, etc.
Frequently Asked Questions (FAQs)
1. How to use the Excel COUNT function?
The COUNT function provides the count of cells containing numbers within the given range of cells. It also counts numeric values within the list of arguments.
The formula of the COUNT in excel is =COUNT(value 1, [value 2],……, and so on).
2. What is the COUNTIF formula?
The COUNTIF function counts cells in a range that meets a single criterion. It counts cells that contain dates, numbers, and text.
The COUNTIF formula in excel is =COUNTIF(range, condition)
Here, the range is a series of cells to count.
3. What is the difference between the COUNT and COUNTA functions in Excel?
The COUNT function is generally used to count a range of cells containing numbers or dates. It excludes blank cells. And the COUNTA function, whichstands for count all, will count the numbers, dates, text, or a range containing a mixture of all these items. It does not count blank cells.
COUNT Function In Excel Video
Download Template
This article must help understand the COUNT function in Excel with its formulas and examples. You can download the template here to use it instantly.
You can download this COUNT Formula Excel Template here – COUNT Formula Excel Template
Recommended Articles
This is a guide to the COUNT Function in Excel. Here, we count number of cells with numeric values, COUNTA, COUNTIF, examples & a downloadable template. You may also look at the below useful functions in Excel –
- Example of COUNTIF with Multiple Criteria
- INT Function in Excel (Integer)INT or integer function in excel returns the nearest integer of a given number and is used when we have many data sets and each data in a different format.read more
- AVERAGE Function in Excel
How to Use the COUNT function in Excel (and COUNTA)
Apart from storing and manipulating numbers, sometimes, you may want to use Excel to simply count numbers.
For example, the number of students in a class, the number of items on a list, etc.
To do so, Excel offers two functions, the COUNT and the COUNTA function. Both the said functions are super easy to operate and can prove very handy. 😀
Read through this tutorial till the end to master both these functions. Also, download our free sample workbook right here to practice alongside you read.
How to use the COUNT function to count cells in Excel
The COUNT function of Excel is going to be one of the simplest functions you’d ever come across.
Take the data in the image below.
1. To count these cells, write the COUNT function as follows.
=COUNT (A1:A6)
2. Here is the count produced by Excel.
Must note how the COUNT function has ignored the blank cell in between.
Pro Tip!
Did you notice how the COUNT function gives results that are not obvious to the eyes? We can see there are five values in the above formula.
The COUNT formula, however, only returns 4 as the count.
This is because the COUNT function only counts certain values that are either:
- Numeric values
- Date and Time values
- Boolean values (TRUE/FALSE)
- Numeric values enclosed in quotation marks (like “10”)
Umbrella is a text value, hence ignored by the COUNT function.
3. If you do not have a cell range to specify, you may also specify values inside the formula separated by a comma.
=COUNT (1, 2, 12/12/22, hello)
Must know that Excel 2007 (and newer versions) can only accept up to 255 values (arguments).
Until Excel 2007, this number was only 30. 🤨
Counting cells in non-adjacent ranges
Can the COUNT function tackle non-adjacent ranges like in the image below?
1. Write the following formula.
=COUNT (A1:A5, B1:B6, C1:C10)
We have specified each non-adjacent range as a separate argument.
2. The COUNT function counts all the non-blank cells.
COUNT vs COUNTA: Count numbers or non-empty cells
What differentiates the COUNT and COUNTA functions? A few things.
1. The COUNT function only counts cells containing specified values. These values include numbers, dates, time, and logical values (TRUE / FALSE). It also counts in numerical values enclosed in Quotation marks (“”).
Any value other than these would not be counted in by the COUNT function. It also ignores any text string.
2. The COUNT function ignores any blank cell in the specified range.
3. The COUNTA function only counts all non-blank cells.
A blank cell means a cell is all blank (no value). If a cell is only apparently blank, the COUNTA function would treat it as a non-blank cell and count it in.
An apparently blank cell may be the one with space even. Or some function the result whereof is a blank cell.
How to use the COUNTA function to count non-empty cells
It’s time we see how the COUNTA function works.
The COUNTA function counts all non-blank cells (containing any values).
Let’s apply the COUNTA function to the data in the image below.
1. Write the COUNTA function as below.
= COUNTA (A1:A10)
2. COUNTA gives the results as follows.
The results show 8 cells. However, we only see 7 cells that contain values.
That’s what you see. One cell in between doesn’t have a value but a space character.
Even if a cell has a space character, the COUNTA function doesn’t treat it as a blank cell. It is included in the count of cells. 😏
The COUNTA function counts all values including text values and ERROR values. Error values include errors posed by Excel like the #NAME! error etc.
Count cells using the status bar
If you’re running out of time and want a quick count of cells containing data – this section is for you.
You can count non-blank cells in Excel without operating a function.
1. Select the cells containing data.
Navigate to the right bottom of your spreadsheet to see the count of cells.
2. Or you can select multiple column headers (or row headers). In this case, Excel will count the number of non-blank cells in each column (or row).
That’s it – Now what?
This guide teaches you the basics of the COUNT and COUNTA functions. It differentiates between them both and explains when should you use each of them.
Both the COUNT and COUNTA functions would help you in many situations. But these are only two very basic functions of Excel.
There’s much more to learn from this giant spreadsheet software. Some functions of Excel that you MUST learn are the VLOOKUP, SUMIF, and IF functions.
Register for my 30-minute free email course that is designed to offer you insights into these functions (and more).
Other resources
There are many advanced versions of the COUNT and COUNTA functions of Excel. For example the COUNTIF function and the COUNTIFS function.
The COUNTIF function counts cells that meet a single criterion. Whereas, the COUNTIFS function counts cells that meet multiple criteria. Check them out here!
Additionally, you may want to learn how to use operators in the COUNTIF Function.
Kasper Langmann2022-11-03T07:04:06+00:00
Page load link
Usage notes
The COUNT function returns the count of numeric values in the list of supplied arguments. COUNT takes multiple arguments in the form value1, value2, value3, etc. Arguments can be individual hardcoded values, cell references, or ranges up to a total of 255 arguments. All numbers are counted, including negative numbers, percentages, dates, times, fractions, and formulas that return numbers. Empty cells and text values are ignored.
Examples
The COUNT function counts numeric values and ignores text values:
=COUNT(1,2,3) // returns 3
=COUNT(1,"a","b") // returns 1
=COUNT("apple",100,125,150,"orange") // returns 3
Typically, the COUNT function is used on a range. For example, to count numeric values in the range A1:A10:
=COUNT(A1:A100) // count numbers in A1:A10
In the example shown, COUNT is set up to count numbers in the range B5:B15:
=COUNT(B5:B15) // returns 6
COUNT returns 6, since there are 6 numeric values in the range B5:B15. Text values and blank cells are ignored. Note that dates and times are numbers, and therefore included in the count.
The COUNTA function works like the COUNT function, but COUNTA includes numbers and text in the count.
Functions for counting
- To count numbers only, use the COUNT function.
- To count numbers and text, use the COUNTA function.
- To count with one condition, use the COUNTIF function
- To count with multiple conditions, use the COUNTIFS function.
- To count empty cells, use the COUNTBLANK function.
Notes
- COUNT can handle up to 255 arguments.
- COUNT ignores the logical values TRUE and FALSE.
- COUNT ignores text values and empty cells.
What is COUNT in Excel?
The COUNT in Excel is a function that counts the number of cells that consists of numeric values in a selected range and ignores all the other entries in the range. For example, the formula “=COUNT(A6:A20)” counts all the cells with numerical values (code number) in the cell range A6:A20, which corresponds to 7.
The COUNT function counts numeric values including the date, time, percentages, negative numbers, formulas, and fractions.
Key Highlights
- The COUNT in Excel is a completely programmed function that can be used for an array
- The COUNT function family has a total of five variants- COUNT, COUNTIF, COUNTIFS, COUNTA, and COUNTBLANK
- To count logical values we use the COUNTA variant of the COUNT function family
- To count numbers meeting certain criteria we use either COUNTIF or COUNTIFS function in Excel
- The function COUNT in Excel does not count formula errors and logical values
- The COUNT function counts dates too as Microsoft Excel stores the dates as serial numbers
- The function COUNT in Excel does not count the logical values- TRUE or FALSE
COUNT in Excel Syntax:
The syntax for the COUNT Function in Excel is-
Explanation:
Value1: It is a required argument of the COUNT function that indicates the first item or cell of the specified range.
Value2: It is an optional argument of the COUNT function in Excel that denotes the second set of cells or ranges that we wish to count. Once we put the first Value1, all other values become optional.
Note: We can provide up to 256 values to the COUNT function.
The return of the COUNT function is always either zero or greater than zero.
How to use the COUNT in Excel?
To understand how we can use the function COUNT in Excel, consider the below examples.
You can download this COUNT in Excel Template here – COUNT in Excel Template
Example #1
The table below shows a list of countries with numerical codes. We want to find the total number of numerical codes from the given list using the COUNT function.
Solution:
Step 1: Place the cursor in cell C7 and enter the formula,
=COUNT(A6:A20)
The above formula will count the numeric values in the given list as shown below
Step 2: Press the Enter key to get the below result
The selected range contains 15 values, but the COUNT function in Excel only counts the numerical values and ignores everything else. As a result, it returns 4 as the total number of numerical codes.
Example #2
The table below shows a list of dates. We want to count the total number of dates using the COUNT in Excel function.
Solution:
Step 1: Place the cursor in cell C8 and enter the formula,
=COUNT(A6:A12)
Step 2: Press the Enter key to get the below result,
The total number of selected cells is seven, but the COUNT function returned the value 5 because two dates in the given list are written in an incorrect format.
The below image shows the dates with incorrect format (highlighted in RED)
Example #3
The table below shows the IDs of five employees, as well as their wages and attendance for the first week of January 2023. If an employee is present, his attendance is marked as 1, and if he is absent, his attendance is marked as A. We want to use the COUNT function in Excel to calculate the Employee’s total wages based on his attendance for the week.
Solution:
Step 1: Place the cursor in cell J6 and enter the formula,
=COUNT(C2:I2)
Step 2: Press the Enter key to get the Total no. of Paid Days as shown below
The COUNT in Excel function returns the Total no. of Paid Days as 6.
Now,
Step 3: Place the cursor in cell K2 and enter the formula,
=B6/7*J6
Step 4: Press the Enter key to get the Total Wages of the week for Empl ID 1005
Step 5: Follow the same steps to get the Total wages for all the Emp IDs to get the below result
COUNT in Excel with IF condition
Syntax-
=IF(logical_test,[value_if_true],[value_if_false])
Example #4
Consider the above example of employees with their IDs, wages, and weekly attendance. Using the COUNT and IF functions, we want to find the employees who are eligible for Full Payment.
Solution:
Step 1: Place the cursor in cell L2 and enter the formula,
=IF (COUNT(C6:I6)=7,”Full Pay”,“Not Full Pay”)
Explanation:
COUNT(C6:I6): There are 7 working days in the week, therefore, an employee present on all the days will be the one eligible for Full Payment.
Thus, the condition is written as COUNT(C6:I6)=7
Step 2: Press the Enter key to get the below result
Now,
Step 3: Enter the same formula in the remaining cells to get the below output
The COUNT function combined with the IF condition shows that only the person with Emp ID- 1D006 is eligible for Full Payment. Since all other employees were absent on one or the other day in that week they are not eligible for full payment.
Difference Between COUNT and COUNTA
- The function COUNT in Excel counts the number of cells having numeric values within a cell range whereas the COUNTA function counts the number of non-empty or blank cells within a given range.
- The function COUNT in Excel counts numeric values and dates whereas the function COUNTA counts all the cells within a range irrespective of the data type.
Syntax of COUNTA function is-
=COUNTA (value1, [value2], …)
Difference between COUNT and COUNTA with Example
The table below shows 10 rows with 6 numeric codes, 2 non-numeric codes, and 2 blank cells.
The COUNT function counts the number of cells with numeric codes and gives the result of 6.
The COUNTA function counts all the cells having codes and excludes the empty cells and gives the result of 9.
Things to Remember
- Only numerical values are counted in the COUNT function.
- The COUNT function ignores empty cells, text and string values, and error values in the array.
- If the COUNT function is applied to an empty range of cells, then the result will always be zero.
- If a text follows the number, COUNT ignores that value also. For example, =COUNT (“145 Number”) would return the result as 0.
- If logical values such as TRUE or FALSE are supplied to the formula, these logical values will be counted by the COUNT function.
- If the same TRUE or FALSE is supplied in a range, then the result will be zero.
- If you want the count of all the values in the given range, then use COUNTA which counts whatever comes it’s way.
Frequently Asked Questions (FAQs)
Q1) How do I count cells in Excel?
Answer: In Excel, we can count cells using any of the COUNT function variants: COUNT, COUNTA, COUNTIF, and COUNTBLANK.
- COUNT: To count cells with numeric values
- COUNTA: To count non-empty cells
- COUNTBLANK: To count blank or empty cells
- COUNTIF: To count cells meeting specified criteria
Q2) What is the significance of COUNT function in MS Excel Class 9?
Answer: We can use the COUNT() function to sum or add the number of cells that contain numbers in the specified cell. The count function can perform the complex calculation of adding numbers in a large data set thus saving a lot of time and effort.
Q3) What is the main difference between COUNT and Countif?
The COUNT in Excel function counts the number of cells containing numeric data or entries whereas the COUNTIF function counts the number of cells meeting the given criteria.
For example, the table below shows students’ Maths marks out of 50. Here, we use the COUNTIF function to count the number of students who have scored more than or equal to 35 and passed the test.
Recommended Articles
The above article is EDUCBA’s guide on using the function COUNT in Excel. For more information related to Excel formulas and functions, EDUCBA recommends the below articles.
- COUNTIFS in Excel
- COUNTA Function in Excel
- Count Names in Excel
- Count Characters in Excel
For getting the count of numbers, dates, text, empty or non-blank cells, you may use various built-in functions in Excel.
Depending on the requirement, you may choose which one to use; for example, if you require the count of cells that contain numbers only, you may use the Excel COUNT function.
To get the count of all cells with numbers, text, dates etc except the blank cells, use the COUNTA function.
Similarly, for returning the count of cells based on certain criteria e.g. count of cells that contain “A” can be done by COUNTIF function and for multiple criteria use the COUNTIFS function. For example, return the count of cells that are between two dates.
To get the count of blank or empty cells, use the COUNTBLANK function.
In the following section, I will show you Count Formulas in Excel with data in spreadsheets. You may copy any formula in your sheet to see how it works.
-
1.
Get the count of numeric cells by COUNT function -
2.
What if cells also contain dates? -
3.
Using multiple ranges in COUNT function -
4.
Using Excel COUNTIF function for conditional counting -
5.
Getting the count of matched text -
6.
Using the ‘*’ wildcard in COUNTIF function -
7.
Using “>=” in COUNTIF for number count -
8.
Using “<” operator in COUNTIF function -
9.
An example of Not equal to operator “<>” -
10.
Getting count of multiple ranges by COUNTIF -
11.
The Example of using COUNTIF with dates -
12.
An example of COUNTA function -
13.
How to get the count of empty cells? -
14.
How to use COUNTIFS function -
15.
The example of using Excel COUNTIFS function -
16.
Using three conditions in COUNTIFS
Get the count of numeric cells by COUNT function
Let us start with a simple example of counting the number of cells that contain numbers only. For that, I have filled cells from A2 to A10 by numbers, text, and blank cells. See what we get by COUNT function:
The COUNT formula:
=COUNT(A2:A10)
You can see, the COUNT function only returned the count for cells containing numbers. The blank and text cells are ignored while numbers with currency format are also included.
What if cells also contain dates?
The COUNT function also reruns the cells that contain dates. To demonstrate that, I extended the above range to B10 cell and added two numbers and two dates in B cells. So, the COUNT formula is:
=COUNT(A2:B10)
See the sheet figure with formula and result:
Using multiple ranges in COUNT function
Two things are further used in this formula. The first is using multiple ranges i.e. A2:A10 and C4:C8. The second thing tested whether COUNT function returns the text with number e.g. “6test”. See the formula and output:
=COUNT(A2:A10,C4:C10)
You saw, the COUNT did not return “2test” occurrence.
You may provide up to 255 ranges, cell references or items that you want to get the count.
Using Excel COUNTIF function for conditional counting
If you require getting the count of the number of cells based on single criteria then use the COUNTIF function. If you separate two words: “COUNT” “IF”, it makes the purpose clear.
For example, COUNT the cells from A2:D1000 IF that contains the word “Microsoft”. Similarly, return the number of cells which date is less than or equal to 10/10/2010 and so on.
General Syntax of COUNTIF:
=COUNTIF(Where to search, What to search)
You may provide a range of cells, array, names range etc as the first argument.
In “What to search” argument, you will specify e.g.
- “London”
- A cell reference like A10
- “>1” count the cells which value is greater than 1
- “<=10” less than or equal to 10
The next section shows a few examples of using the Excel COUNTIF function.
Getting the count of matched text
In this example, we will get the count of “Apple” in our example sheet. The column A cells contain the Fruits and Vegetable names. In the COUNTIF function, I specified the Apple as follows:
The result:
You can see the text Apple occurred three times in the given range.
Using the ‘*’ wildcard in COUNTIF function
You may also use the wildcards (* and ?) in the COUNTIF function. The ‘*’ is used for any sequence of characters while ‘?’ mark for the single character.
In the following example, I used the “to*” in the COUNTIF for the same sheet as used in above example and see the formula and result:
The COUNTIF formula:
The result:
You saw the occurrences of Tomato (twice) and Potato (once) is returned as 3.
Using “>=” in COUNTIF for number count
For this example, I will use the single criteria for counting the cells containing the number of sales greater than or equal to 100 in the COUNTIF function.
For this example, the Excel sheet contains month names in B cells and number of sales in C cells. Following COUNTIF formula is used:
The resultant sheet:
If you count the number of sales greater than or equal to 100, it is 6 that COUNTIF returned.
Using “<” operator in COUNTIF function
Now, we will get the count of Number of Sales less than 100 by using COUNTIF function. The following formula is used:
The count is again 6.
An example of Not equal to operator “<>”
For this example, I used the Not Equal to operator which is “<>”. The criterion set in the COUNTIF is to return the number of sales not equal to 150 i.e.
Result:
If you look at the data in the Excel sheet, it contains 150 twice. So, the COUNTIF omitted these and returned 10 counts.
Getting count of multiple ranges by COUNTIF
In this example, we will get the count of two different ranges by using COUNTIF function twice and adding the returned result.
For that, I have added another column in above sheet i.e. Amount. By using the COUNTIF function, we will get the count of (number of sales more than 100) + (Sale amount greater than or equal to $15000). See how this is translated into COUNTIF:
=COUNTIF(C2:C13,«>100»)+COUNTIF(D2:D13,«>=15000»)
The returned result:
If you count the C cells (C2:C13) then the count of cells with more than 100 sales is 6. Add this to the count of D2:D15 cells with the amount greater or equal to 15000 then it is 7. The sum of both returned values is 13.
Note: Please do not mix it with using multiple conditions. The COUNTIF returned results separately and its result is summed. If we used minus operator then result would have been -1 i.e.
=COUNTIF(C2:C13,«>100») — COUNTIF(D2:D13,«>=15000»)
You may use more than two COUNTIF formulas as well. The function of using multiple conditions/criteria is COUNTIFS that is coming up in next sections.
The Example of using COUNTIF with dates
Just like the numbers, you may also write a criterion for date columns to get the count. For example, get the count of employees who joined after 3rd Jan 2012.
To demonstrate the usage of dates in COUNTIF function, I am using an Excel sheet containing fictitious records of employee names and their joining date. A named range is created which is referred to the COUNTIF function.
By using COUNTIF function, we will get the total count of employees, number of employees joined after 2010, the number of employees joined before 2007 and employees joined between 2008 to 2012. First, have a look at the resultant sheet which is followed by COUNTIF formulas:
The formula to get the total number of employees:
=COUNT(empData)
Where empData is the range name containing cells A3 to B7.
The COUNTIF formula for getting the number of employees joined after 2009:
=COUNTIF(empData, «>» & «2009-12-31»)
Joined on or before 2007:
=COUNTIF(empData, «<=» & «2007-12-31»)
Joined between 2008 to 2012 formula:
=COUNTIFS(empData,«>=»&«2007-01-01»,empData,«<=»&«2012-12-31»)
The last formula used COUNTIFS as we have two conditions to check. I will explain this in the COUNTIFS section.
You may learn more about the COUNTIF function in its tutorial: Using COUNTIF function.
An example of COUNTA function
If you require counting cells containing any type of data including numbers, text, empty string e.g. “”, dates, cells with error codes etc. then use the COUNTA function.
The COUNTA function will only omit the empty cells. See the following example, where I have used different types of values in Excel sheet and used COUNTA function for getting the count:
The COUNTA formula:
=COUNTA(B2:B10)
You can see, the resultant sheet displayed count as 7 as two cells in the given range are empty.
How to get the count of empty cells?
If you require the count of empty cells only then use the COUNTBLANK function. Have a look at the same Excel sheet and data as used for COUNTA function for demonstrating the COUNTBLANK function.
The Excel COUNTBLANK formula:
=COUNTBLANK(B2:B10)
The returned count is 2 as you can see the given range contains two blank cells.
How to use COUNTIFS function
As mentioned earlier, if you have multiple criteria to check for getting the count in a range, array etc. you may use the COUNTIFS function.
For example, return the count of those employees who joined after 10/20/2012 and their salary is $5000 or above. We have seen, the COUNTIF enables using single criterion only whereas COUNTIFS allows us getting the count based on above two criteria.
The example of using Excel COUNTIFS function
For the example of COUNTIFS function, I am using the same Excel sheet as used in an above example that contains Months, Number of Sales and Amount columns.
The requirement is to count those rows which Number of Sales is greater than or equal to 110 and amount >= $15000. The COUNTIFS formula is:
=COUNTIFS(C2:C13,«>=110»,D2:D13,«>=15000»)
The result:
You can see, the highlighted rows met both criteria. If you look at the first row, the amount is $15000 that is true, however, the Number of sales is 105 which is False; so COUNTIFS did not include this row.
Using three conditions in COUNTIFS
You may use up to 127 range/criteria pairs in the COUNTIFS function. In this example, I am using three conditions in the COUNTIFS. For that, extending the above formula and another criterion is added to return the count of those rows that start with month “J”. While the number of sales is set as greater than 100.
The COUNTIFS formula:
=COUNTIFS(B2:B13,«J*»,C2:C13,«>100»,D2:D13,«>=15000»)
The result:
You see, I used ‘*’ wildcard as the first criteria i.e. B2:B13,”J*”. If you go through the table, only two highlighted rows met all the criteria given in COUNTIFS function.