Skip to main content

Count Formula in Excel: Essential Tips and Examples

Learn how to use Excel’s COUNT() formula with essential tips, real-world examples, and variations like COUNTA(), COUNTBLANK(), and COUNTIF() to handle different data types and scenarios.
Jun 25, 2025  · 9 min read

One of its most underrated formula in Excel is the COUNT() formula (or, more exactly, the COUNT() function). It can save you time, reduce errors, and make your data analysis a whole lot smoother.

In this guide, I’ll walk you through Excel’s count functions in a way that’s practical and easy to follow, whether you’re just getting started with Excel or have been using it for years.

What Is the COUNT() Formula in Excel?

The COUNT() function in Excel counts the number of numeric values within a specified range of cells. Its primary purpose is to determine how many cells contain numbers. 

For example, if you're managing a sales report or tracking test scores, COUNT() helps you identify how many valid numerical entries are present.

You can use this function when you need to:

  • Count how many items have a price entered
  • Identify how many students submitted numeric grades
  • Summarize the number of responses in a survey containing numeric data

By speeding up the counting process, COUNT() saves time and reduces the risk of manual errors in data analysis.

COUNT() Formula Syntax and Explanation

The syntax for using the COUNT() formula is:

COUNT(value1, [value2], ...)

Let’s understand this:

Argument

Status

Description

value1

Required

Cell reference or range in which numbers need to be counted

[value2]

Optional

Cell references or ranges in which numbers need to be counted. But this can accommodate up to 255 additional items.

The COUNT() function only includes numbers, dates, and numeric text (like 1 if entered directly as an argument). It ignores text, logical values (like TRUE or FALSE), error values, and empty cells when these are part of a range.

How to Use the COUNT() Formula

Let’s see how you can use the COUNT() function for real-world work. 

Example 1: Counting simple numeric data

First, we’ll cover how to count numeric values in a range:

Suppose we have two columns: Roll No and Marks. Some cells in the Marks column are empty.

To count how many numeric entries are in the Marks column:

=COUNT(B2:B11)

COUNT function in Excel

Since 2 out of 10 cells are empty, the formula returns 8, representing 8 numeric values in the range.

We can also include additional numeric values outside the range. Here’s how:

=COUNT(B2:B11, 20)

COUNT function in Excel

This formula counts the eight numeric values in B2:B11 plus the extra 20, so it returns 9.

Example 2: Counting dates and times

Let’s say you’re managing an employee attendance sheet where each row records a check-in date and check-in time. In some cases, employees might forget to fill in the date or time, or someone might have entered a note instead of a proper date. I wrote "Hello," which obviously doesn't fit.

dataset for count function in excel

This is what the COUNT() function helps with. You can quickly check how many valid numeric entries you actually have.

In Excel:

  • Dates are stored as numbers (counting days since January 1, 1900).

  • Times are stored as fractions of a 24-hour day (for example, 0.5 is 12:00 PM).

Since both are numeric, COUNT() will include them when tallying values.

For the date column, I use the following formula:

=COUNT(A2:A6)

Counting number of date cells with COUNT function in Excel

And for the time column, I use the following formula:

=COUNT(B2:B6)

counting number of time cells using COUNT function in excel

Both formulas return 3 because in each column, there are only 3 numeric values. In the cells A2 through A6:

  • A2 > numeric
  • A3 > numeric
  • A4 > blank (not counted)
  • A5 > text (not numeric)
  • A6 > numeric

Similarly, in cells B2 through B6:

  • B2 > numeric
  • B3 > numeric
  • B4 > blank (not counted)
  • B5 > blank (not counted)
  • B6 > numeric

Example 3: Using named ranges

Named ranges in Excel allow us to assign a custom name to a cell or range of cells. When used with functions like COUNT(), they make formulas easier to read and reuse dynamically.

For this example, I’m using the following data:

data for calculating named ranges in excel

First of all, we need to define a named range. To do that:

  • Select the cells containing your sales figures: C2:C6.

  • Go to Formulas > Define Name, and give it a name like SalesData.

defining a named range

Now, instead of writing:

=COUNT(C2:C6)

You can simply write:

=COUNT(SalesData)

COUNT() function with named range

The formula returns 5 because all five cells contain numeric values.

result of the example in excel

But why should you use named ranges? Because it has two major benefits:

  1. Flexibility: If your data range changes (e.g., you add more rows for additional sales figures), you only need to update the named range once—no need to edit every formula that refers to it.

  2. Reusability: You can use SalesData in any formula, in any part of the workbook, without worrying about cell references.

Example 4: Combining COUNT() with other functions

To perform more complex and insightful calculations, we can nest COUNT() inside other functions, too. Suppose you want to calculate the average of all numbers in a range, but ignore any text or blanks, and also display how many numeric entries were used in the calculation.

So here’s how you can do that by combining COUNT() with SUM():

=SUM(A2:A6)/COUNT(A2:A6)

calculating the average using SUM and COUNT in excel

Similarly, you can also use COUNT() with an IF() statement for logical testing:

=IF(COUNT(C2:C7)>0, SUM(C2:C7)/COUNT(C2:C7), "No numbers")

This formula displays the average only if there are numeric values; otherwise, it shows No numbers.

combine count function with if in excel

You can even nest the COUNT() function for data reporting and summarization, as it works well in dashboards and dynamic sheets.

Let’s say you want to use COUNT() for reporting. Here’s how you can use COUNT() with embedded text:

="There are " & COUNT(C2:C7) & " numeric values."

use the count function for data reporting in excel

Troubleshooting COUNT() Formula Errors

Even though Excel’s COUNT() functions are generally easy to use, it’s normal to run into unexpected results. Let’s look at common issues and see how to fix them so your counts stay accurate.

Resolving #NAME? and #VALUE! errors

When working with COUNT() and related functions, two common errors you might see are #NAME? and #VALUE!. Let’s explore what causes them and how you can fix them.

#NAME? Error

This happens when Excel doesn’t recognize the function or named range you’ve entered, usually because of a typo. Here’s how you can fix this:

  • Double-check the spelling of your function name. For example, typing COUUNT() instead of COUNT() will trigger a #NAME? error.

  • Make sure any named ranges you reference are defined correctly.

  • Check that text criteria are properly enclosed in quotes when needed.

#VALUE! Error

This error appears when COUNT() gets an argument it can’t process like a text string, where it expects a range or numeric value. For example: =COUNT("text")

Since COUNT() expects numeric values or ranges, not plain text, this will throw a #VALUE! error. 

To fix this:

  • Ensure your arguments are valid ranges or numeric data.

  • If you want to count text, use COUNTA() instead.

Avoiding blank cells and hidden data issues

Sometimes, COUNT() results can be confusing because of how blanks, hidden rows, or formatting are treated:

Blanks and empty strings

If you want to test what’s really in a cell, try:

=LEN(cell)

This shows the number of characters in the cell, so you can spot invisible content like spaces.

Hidden rows

All COUNT() functions include hidden rows in their counts. If you want to count only visible (filtered) rows, do this:

=COUNT(102, range)

Here, 102 tells Excel to count numeric values in visible cells only (used with the SUBTOTAL function).

Formatting issues

Sometimes a cell looks like a number but is actually stored as text, so COUNT() ignores it. For example, "100" stored as text won’t be counted:

  • =ISTEXT(cell) returns TRUE if it’s text  

  • =ISNUMBER(cell) returns TRUE if it’s a number

To avoid surprises, convert text numbers to real numbers, and replace unnecessary blanks with default values where possible.

Other Count Functions: COUNTIF(), COUNTA(), and More

Beyond the basic COUNT() function, Excel offers advanced counting functions like COUNTA(), COUNTBLANK(), and COUNTIF(). These functions give us more flexibility for data analysis, whether we want to count all non-empty cells, identify missing data, or apply conditions to our counts. 

Let’s understand these with simple and practical examples.

Using the COUNTA() function for non-empty cells

The COUNTA() function counts all non-empty cells in a range. This includes cells containing numbers, text, logical values (TRUE, FALSE), errors, or any other data. It’s great for checking data completeness.

Suppose we have a range that contains numbers, text, and errors, plus one empty cell.

=COUNTA(A2:A6)

counta() function in excel

The formula counts all filled cells, so if 4 cells have data and 1 is empty, it will return 4.

You can use this formula to check if all rows have some data entered and identify the completeness of forms or surveys

Identifying empty cells with COUNTBLANK()

COUNTBLANK() counts the number of empty cells in a range of cells. But it does not count cells with a zero value because 0 is a number, not blank. Its syntax is:

= COUNTBLANK(range)

Here, range is a required argument that defines the range from which we want to count the blank cells. 

In the example below, we have a mix of numbers, text (here I put "Hello" again), and empty cells. Let’s see how COUNTBLANK() helps us identify those gaps.

counta() function example in excel

The formula returns 2 because there are only two cells that are blank.

Conditional counting with COUNTIF()

COUNTIF() allows us to count cells that meet a specific condition, like numbers above a threshold, specific text, or patterns using wildcards. This makes it helpful for filtering and summarizing data.

Its syntax is:

=COUNTIF(range, criteria)

Here:

  • range is where you want to look

  • criteria is what you want to look for

Let’s say we’re tracking sales figures and we want to know how many values in our dataset are above 100:

=COUNTIF(B2:B6, ">100")

countif() function in excel

As a result, it returns 1 because only one cell in the range contains a value over 100.

Now imagine you’re managing order statuses, and you want to count how many items are still marked as pending so we can follow up or report progress. To do so, you can use the following formula:

=COUNTIF(C2:C6, "pending")

countif() function example in excel

The formula above returns 2 as two cells contain “pending” in the specified range. 

Let's do a third example. Suppose we have a list of items, sales, and statuses, and we want to count how many start with the letter A. To do so, you can use the following formula: 

=COUNTIF(A2:A6, "A*")

countif() function in excel

It returns 2 because two cells in the range start with A.

Conclusion

Excel’s counting functions are incredibly helpful. When you know how to apply them, you can clean up your spreadsheets, spot gaps, and create reports that are accurate and reliable.

Try adding these formulas to your everyday Excel tasks. You’ll notice they save time and help you feel more in control of your data. Small techniques like these can make a big difference, and the best way to master them is to start using them today. Enroll in our Advanced Excel Functions course to really build data analysis and productivity skills.


Laiba Siddiqui's photo
Author
Laiba Siddiqui
LinkedIn
Twitter

I'm a content strategist who loves simplifying complex topics. I’ve helped companies like Splunk, Hackernoon, and Tiiny Host create engaging and informative content for their audiences.

FAQs

How do you count rows in Excel?

To count rows in Excel, click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count.

How do you count characters in Excel?

You can use the =LEN(cell) function to count characters in Excel. For example: =LEN("APPLE")

This will return 5, since the word APPLE has 5 characters.

How do you autofill in Excel?

To use AutoFill in Excel, enter your initial data in a cell. Then, move your cursor to the bottom-right corner of the cell until it transforms into a small cross (the fill handle). 

Click and drag the fill handle down or across to the desired range of cells, and Excel will automatically fill the cells with the data, formulas, or series you're using.

What is MAX() in Excel?

The MAX() function is a premade Excel function that finds the highest number in a range: 

=MAX (cell range).

Topics

Learn Excel with DataCamp

Track

Excel Fundamentals

0 min
Gain the essential skills you need to use Excel, from preparing data to writing formulas and creating visualizations. No prior experience is required.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

Tutorial

COUNTIF() Excel: Count Cells Based on Conditions

Use Excel’s COUNTIF() function to quickly count cells matching specific criteria like text, numbers, dates, and wildcard characters.
Laiba Siddiqui's photo

Laiba Siddiqui

8 min

Tutorial

How to Count Unique Values in Excel: What You Need to Know

Learn to count unique values in Excel using basic and advanced formulas. See the difference between unique and distinct values.
Laiba Siddiqui's photo

Laiba Siddiqui

8 min

Tutorial

SUBTOTAL() Formula in Excel: A Full Calculation Guide

Learn how the SUBTOTAL() function dynamically summarizes filtered or grouped data. Understand its syntax, explore practical examples, and compare it with similar functions.
Vinod Chugani's photo

Vinod Chugani

9 min

Tutorial

How to Sum in Excel: A Full Guide

Learn how to add numbers in Excel using built-in tools. Explore multiple methods for quick calculations, including formulas, keyboard shortcuts, and table formatting.
Laiba Siddiqui's photo

Laiba Siddiqui

9 min

Tutorial

COUNT() SQL FUNCTION

COUNT() lets you count the number of rows that match certain conditions. Learn how to use it in this tutorial.
Travis Tang 's photo

Travis Tang

3 min

Tutorial

Rank Formula in Excel: A Comprehensive Guide With Examples

Learn how to rank data in Excel with RANK(), RANK.EQ(), and RANK.AVG() functions. Understand their differences, applications, and tips for accurate data analysis.
Laiba Siddiqui's photo

Laiba Siddiqui

11 min

See MoreSee More