Skip to main content

How to Count Non-Blank Cells in Excel: 5 Main Methods

Learn how to count non-blank cells in Excel using COUNTA(), COUNTIF(), COUNTIFS(), SUBTOTAL(), and SUMPRODUCT() with LEN().
Feb 23, 2026  · 10 min read

Counting non-blank cells sounds simple until you try it. You write a quick COUNTA() formula and the number doesn't match what you see on screen. Some cells look empty, but get counted. Others have data, but get skipped.

In this tutorial, I'll walk you through every method for counting non-blank cells: COUNTA(), COUNTIF(), COUNTIFS(), SUBTOTAL(), and SUMPRODUCT(). I'll show you when to use each one, what mistakes to avoid, and how to fix the problems I keep seeing. By the end, you'll know which function to reach for in any situation.

Count Non-Blank Cells Using COUNTA()

COUNTA() is my go-to function for counting non-blank cells. It counts anything that's not completely empty: text, numbers, dates, errors, and even formulas that return empty strings.

counting non blank excel cells

How COUNTA() works

The syntax is simple:

=COUNTA(value1, [value2], ...)

value1 is the range you want to count. You can add up to 255 arguments, but you'll usually just use one range.

Here's an example from a survey tracker I built last month. I had 12 respondents, but some people skipped questions and others quit halfway through. I needed to know how many people actually gave me an email address.

=COUNTA(B2:B13)

This gave me 10 because two people (Ahmed Hassan and Mohamed Ali) left the email field blank.

COUNTA() counts ten non-blank email cells. Video by Author.

I can also count across a row to see how complete each person's response is:

=COUNTA(B2:F2)

For Sara Ibrahim, this returns 5 because she filled in every field. For Nour Mahmoud, =COUNTA(B6:F6) returns just 1 since she only provided her email and abandoned the rest.

COUNTA() shows completion level per respondent. Video by Author.

When COUNTA() is enough

Use COUNTA() when you need a simple count and your data is clean. If every blank cell in your range is genuinely empty (never touched, no formulas), COUNTA() works perfectly.

Where things get messy is when formulas return "" (empty strings). I'll explain that edge case in detail later in the "How Excel Treats Blank vs. Empty Cells" section.

Count Non-Blank Cells Using COUNTIF()

COUNTIF() gives you another way to count non-blank cells. Instead of counting everything that exists, it counts cells that match a condition. And that condition can be "not empty."

The "<>" criteria

Here's what the formula looks like:

=COUNTIF(B2:B13,"<>")

The "<>" part means "not equal to nothing," which is just another way to say "not blank." For the same email column from before, this gives me 10, same as COUNTA().

COUNTIF() with "<>" matches COUNTA()'s result here. Video by Author.

Why not use COUNTIF(range,"*")?

I see this in older tutorials, and it's a mistake. The wildcard "*" only counts text. It completely ignores numbers, dates, and TRUE/FALSE values. If your column has mixed data types, you'll get the wrong count.

Stick with "<>" instead. It works no matter what type of data you have.

When COUNTIF() is better than COUNTA()

The real advantage of COUNTIF() is that it leads naturally to COUNTIFS(). Once you need to count non-blank cells that also meet other conditions (like a specific department or date range), COUNTIFS() is right there waiting. If you think you might add conditions later, start with COUNTIF() so the switch is easy.

For most data, COUNTA() and COUNTIF(range,"<>") give identical results. Both count the same things, including errors and formula-generated blanks. The main difference is flexibility. COUNTIF() is your bridge to multi-criteria counting with COUNTIFS().

Count Non-Blank Cells That Meet Conditions

This is where COUNTIF() really starts to shine. COUNTIFS() lets you count non-blank cells that also meet other conditions.

COUNTIFS() with non-blank logic

Let's say I'm tracking employee training and I want to know how many people in Sales have submitted a score. Here's the formula:

=COUNTIFS(B2:B11,"Sales",E2:E11,"<>")

This means: "Count rows where Department is 'Sales' AND Score is not blank." In my tracker, this gives me 3 because Mona Sayed is in Sales but hasn't turned in a score yet.

`COUNTIFS()` counts Sales staff with scores filled. Video by Author.

Multiple conditions

You can stack up to 127 criteria pairs if you need to. Here's one that counts employees marked "Complete" who also have a score:

=COUNTIFS(C2:C11,"Complete",E2:E11,"<>")

This gives me 6 because Mona Sayed completed her training but never submitted a score.

Another example. Counting Engineering folks who have completion dates:

=COUNTIFS(B2:B11,"Engineering",D2:D11,"<>")

This returns 3 since Omar Mostafa's training is still pending and has no date yet.

Multiple COUNTIFS() formulas target different criteria. Video by Author.

The pattern is simple: use "<>" for the column you're checking for non-blank values, and put your specific filters in the other columns.

How Excel Treats "Blank" vs. "Empty" Cells

This is where most counting mistakes happen. Excel sees different types of "empty" that all look the same on screen.

Truly empty cells

A truly empty cell has never been touched or has been cleared completely. ISBLANK() returns TRUE, COUNTA() skips it, and COUNTBLANK() counts it. This is the only type of cell that all functions agree is blank.

Formula-generated empty strings

This one catches people all the time. When a formula like =IF(A1>60,"Pass","") returns "", the cell looks empty but actually contains a formula result. Here's how different functions see it:

  • COUNTA() → Counts it (non-blank)
  • COUNTIF(range,"<>") → Counts it (non-blank)
  • COUNTBLANK() → Counts it (blank)
  • ISBLANK() → Returns FALSE

See the problem? COUNTBLANK() says it's blank, but ISBLANK() says it's not. This trips up even people who've been using Excel for years.

Different functions disagree on formula-generated blanks. Video by Author.

The SUMPRODUCT() + LEN() workaround

To count only cells with actual visible content (no formula blanks, no spaces), use this:

=SUMPRODUCT(--(LEN(B5:B10)>0))

This checks how many characters each cell has. If LEN() returns 0, the cell is blank no matter what. The -- part converts TRUE/FALSE to 1/0, and SUMPRODUCT()` adds them up.

For an even stricter count that also ignores cells with spaces:

=SUMPRODUCT(--(LEN(TRIM(B5:B10))>0))
SUMPRODUCT() with LEN() catches formula-generated blanks. Video by Author.

Cells with hidden characters

Sometimes a cell looks empty but has a space in it (CHAR(32)) or a non-breaking space (CHAR(160)) from web data or PDFs. COUNTA() counts it, LEN() returns 1 or more, and ISBLANK() says FALSE.

To catch these in your count, use the stricter formula I showed earlier: =SUMPRODUCT(--(LEN(TRIM(range))>0)). The TRIM() part removes regular spaces before counting. For non-breaking spaces, clean your data first with =SUBSTITUTE(A1,CHAR(160),"") or use the CLEAN() function.

Count Non-Blank Cells in Filtered Data

Here's something that catches people off guard: you filter your data, write a COUNTA() formula, and the result still includes the hidden rows. That's because COUNTA() doesn't care about filters. It counts everything in the range, whether you can see it or not.

SUBTOTAL(): The filter-aware alternative

SUBTOTAL() fixes this. It counts things while respecting filters.

=SUBTOTAL(3,D2:D11)

The 3 tells SUBTOTAL() to do a COUNTA()-style count. The difference: it skips rows that are hidden by filters.

SUBTOTAL() counts only visible non-blank cells. Video by Author.

Function numbers: 3 vs. 103

SUBTOTAL() has two modes:

  • Function number 3: Skips rows hidden by AutoFilter, but still counts manually hidden rows.
  • Function number 103: Skips ALL hidden rows (both filter and manual).
=SUBTOTAL(3,D2:D11)    -- Skips AutoFilter rows
=SUBTOTAL(103,D2:D11)  -- Skips ALL hidden rows

Most of the time, 3 is what you need. Use 103 only if you've manually hidden rows (right-click > Hide) and want those excluded too.

AGGREGATE(): An alternative for messy data

If your filtered data has error values in it, SUBTOTAL() will throw an error. AGGREGATE() handles this better:

=AGGREGATE(3,7,D2:D11)

The 3 is the function number (COUNTA()), and 7 tells it to ignore both hidden rows and errors. This is the safest option for messy data, but most people don't need it.

Counting Non-Blank Cells in Excel Tables

If your data is in an Excel Table (hit Insert > Table or press Ctrl+T), you can use structured references instead of cell addresses. This makes your formulas clearer and they update automatically when the table grows.

Structured references with COUNTA()

Instead of writing =COUNTA(C2:C9), you write:

=COUNTA(TaskTracker[Assigned To])

This counts non-blank cells in the Assigned To column of my TaskTracker table. The reference skips the header row automatically and expands when I add new rows.

COUNTA() with structured references adjusts when the table grows. Video by Author.

Combining COUNTIFS() with structured references

COUNTIFS() works great with tables:

=COUNTIFS(TaskTracker[Status],"Done",TaskTracker[Completion Date],"<>")

This counts tasks marked "Done" that have a completion date. In my tracker, this gives me 4 since all completed tasks have dates.

Why tables are better for counting

Two things make tables useful. First, structured references skip the header row automatically, so you don't need to worry about starting from row 2. Second, when you add a new row to the table, every formula using structured references picks up the new data. No need to manually update ranges.

This is perfect for data that grows over time, like logs, trackers, or data you import regularly.

Common Problems When Counting Non-Blank Cells

Count is higher than expected

What happens: COUNTA() says 6, but you only see 4 cells with data.

Why: Two cells have formulas that return "". As I mentioned earlier, these look empty but technically aren't.

Fix: Use =SUMPRODUCT(--(LEN(range)>0)) instead of COUNTA(). This only counts cells with visible content, ignoring formula-generated blanks.

COUNTA() overcounts when formulas return empty strings. Video by Author.

Hidden spaces mess up the count

What happens: A cell looks empty, but COUNTA() counts it and ISBLANK() says FALSE.

Why: The cell has spaces in it, probably from copying data from a website or another file.

Fix: Check with =LEN(A1). If it returns more than 0 when the cell looks empty, you've got hidden characters. Clean your data first with =TRIM(A1), or use the stricter formula I showed earlier: =SUMPRODUCT(--(LEN(TRIM(range))>0)).

LEN() reveals hidden spaces TRIM() can remove. Video by Author.

Error values get counted when you don't want them

What happens: You want to count non-blank cells but errors like #DIV/0! or #N/A get included.

Why: Both COUNTA() and COUNTIF(range,"<>") treat errors as non-blank.

Fix: If your data also has filters, use =AGGREGATE(3,7,range) like I mentioned in the filtered data section. The 7 skips both hidden rows and errors. For non-filtered data, use =SUMPRODUCT(--(LEN(IFERROR(range,""))>0)).

Count doesn't update after filtering

What happens: You filter your data and COUNTA() still shows the unfiltered count.

Why: COUNTA() ignores filters completely.

Fix: Use =SUBTOTAL(3,range) as I covered in the filtered data section. It automatically adjusts based on what's visible.

Best Practices for Counting Non-Blank Cells

After dealing with these issues more times than I should admit, here's what I do now:

  • Start with COUNTA() for clean, simple datasets. It's fast and straightforward.

  • Use COUNTIF(range,"<>") if you might add conditions later. It connects naturally to COUNTIFS() for multi-criteria counting.

  • Test for formula blanks before trusting the count. Spot-check a few "empty" cells with =LEN(cell). If you get anything other than 0, switch to the SUMPRODUCT()+LEN() approach.

  • Use SUBTOTAL(3,range) for filtered data. It's the only counting function that respects filters.

  • Clean imported data first. Run TRIM() and check for CHAR(160) on data from websites or other sources.

  • Use Excel Tables for growing datasets. Structured references update automatically when you add rows.

  • Document complex formulas. If you're using SUMPRODUCT(--(LEN(TRIM(range))>0)), add a comment explaining why. Future you will thank you.

Conclusion

Excel gives you several ways to count non-blank cells, and the right one depends on your situation. COUNTA() works for most cases. COUNTIF() and COUNTIFS() let you add conditions. SUBTOTAL() respects filters. And SUMPRODUCT() with LEN() is your backup when formulas create invisible blanks.

The trick isn't memorizing formulas. It's understanding what Excel thinks "blank" means. A formula returning "" looks empty but isn't. A space character is invisible but gets counted. Once you get these differences, you won't get surprised by wrong counts anymore.

If you want to keep building your Excel skills, check out our Data Analysis in Excel course. It covers formulas, pivot tables, and data cleaning that goes well with everything we covered here.


Khalid Abdelaty's photo
Author
Khalid Abdelaty
LinkedIn

I’m a data engineer and community builder who works across data pipelines, cloud, and AI tooling while writing practical, high-impact tutorials for DataCamp and emerging developers.

FAQs

What's the fastest way to count non-blank cells in Excel?

Just select your range and look at the status bar at the bottom of Excel. It shows "Count" automatically without any formula. This is great for a quick check. If you need the count in a cell for calculations, use =COUNTA(range).

Why does COUNTA() count cells that look empty?

Those cells probably have formulas returning "" or hidden spaces from copy-paste. Use =LEN(A1) to check. If it returns more than 0, the cell isn't truly empty. The fix is =SUMPRODUCT(--(LEN(range)>0)) which only counts cells with visible content.

What happens if I use COUNTA() on filtered data?

COUNTA() ignores filters and counts everything, including hidden rows. Use =SUBTOTAL(3,range) instead. It automatically skips filtered rows. This is especially useful in reports where users apply their own filters.

Can COUNTIF() count non-blank cells faster than COUNTA()?

COUNTA() is simpler for basic non-blank counts. Use COUNTIF(range,"<>") when you need condition-based logic or when you plan to extend the formula later with COUNTIFS(). The difference in performance is negligible for typical datasets.

How do I exclude formula-generated blanks from my count?

Use =SUMPRODUCT(--(LEN(TRIM(range))>0)). This counts only cells with actual visible characters. The TRIM() part also removes any hidden spaces, making it a very robust method for messy data that contains formula blanks and extra spaces.

Topics

Learn Excel with DataCamp

Track

Excel Fundamentals

16 hr
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

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.
Laiba Siddiqui's photo

Laiba Siddiqui

Tutorial

COUNTBLANK() Function in Excel: Identify Gaps in Your Data

Learn how to use the Excel COUNTBLANK() function to quickly identify and count empty cells in your data.
Josef Waples's photo

Josef Waples

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

Tutorial

Remove Blank Rows in Excel: 4 Easy Methods

Learn how to remove extra rows quickly using sorting, formulas, and VBA, depending on what works best for you.
Laiba Siddiqui's photo

Laiba Siddiqui

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

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

See MoreSee More