Google Sheets Count If Not Empty: 4 Easy Formulas

How-to basics · Updated November 23, 2026

The simplest way to count non-empty cells in Google Sheets is =COUNTA(A:A), which counts every cell that contains any value, including text, numbers, and errors, but excludes truly blank cells. If you need to count only cells that are not empty while ignoring cells that contain formulas returning an empty string (“”), use =COUNTIF(A:A,"<>"&"") or =SUMPRODUCT((A:A<>"")*1). This article explains each method, when to use them, and how to avoid common pitfalls.

What “Not Empty” Actually Means in Google Sheets

Before choosing a formula, you need to know how Google Sheets treats different kinds of cells. A cell is considered “empty” only if it has no content at all. But there are two tricky cases that often confuse users:

  • Cells with formulas returning an empty string (e.g., =IF(A1="","",A1)) look blank but are not empty. COUNTA counts them as non-empty because they contain a formula.
  • Cells with spaces (a single space typed in a cell) are also counted by COUNTA because a space is a text character.
  • Cells with errors (like #N/A) are counted by COUNTA because they contain a value.

So the “right” formula depends on whether you want to count cells that are truly blank (no formula, no space) or cells that just display nothing.

The Basic Formula: COUNTA

The most direct answer to “count if not empty” is the COUNTA function. It counts all values in a dataset, ignoring blank cells. For example, with values in A1:A10 where A1 has “apple”, A2 is blank, A3 has 5, and A4 has a formula returning “”, the formula =COUNTA(A1:A10) returns 3 (apple, 5, and the formula cell).

Syntax: =COUNTA(value1, [value2, ...]) or a range like =COUNTA(A:A) to count the entire column. It works on a single range or multiple ranges separated by commas.

Note: COUNTA also counts logical values (TRUE/FALSE) and error values. If you want to exclude errors, you can wrap with IFERROR but that gets complex. For most counting needs, COUNTA is sufficient.

Counting Non-Empty Cells with COUNTIF

If you need to count cells that are not empty but also want to exclude cells that contain formulas returning an empty string, use COUNTIF with the criteria "<>"&"". The <> means “not equal to”, and concatenating with an empty string tells Sheets to treat “” as the comparison value.

Example: With names in A2:A20, where some cells have formulas like =IF(B2="","",B2) that return “”, use =COUNTIF(A2:A20,"<>"&""). This counts cells that are not equal to an empty string, effectively ignoring both truly blank cells and those with “” results.

Important: This formula still counts cells containing spaces. To exclude spaces, you’d need a more advanced approach like =SUMPRODUCT((TRIM(A2:A20)<>"")*1), which trims spaces before checking.

Using SUMPRODUCT for Advanced Control

When you need to count non-empty cells with multiple conditions—like ignoring spaces or checking across multiple columns—SUMPRODUCT is the most flexible tool. It evaluates each cell in a range and sums the results of a logical test.

Example: To count cells in A2:A100 that are not empty and also not just spaces, use =SUMPRODUCT((TRIM(A2:A100)<>"")*1). The TRIM function removes leading/trailing spaces, so a cell with only spaces becomes “” and is not counted. The *1 converts TRUE/FALSE to 1/0.

You can also combine conditions, like counting non-empty cells in column A where column B is “Yes”: =SUMPRODUCT((A2:A100<>"")*(B2:B100="Yes")). This returns the count of rows where both conditions are true.

Counting Non-Empty Cells in Multiple Columns or Rows

Sometimes you need to count across a 2D range, like A1:C10. COUNTA works directly: =COUNTA(A1:C10) counts all non-empty cells in that rectangle. For COUNTIF, you can also use a range: =COUNTIF(A1:C10,"<>"&"").

If you need to count per row or per column, you can use BYROW or BYCOL (available in newer Sheets). For example, to get a count of non-empty cells in each row of A1:C10, use =BYROW(A1:C10, LAMBDA(row, COUNTA(row))). This returns an array of counts, one per row.

Common Mistakes and How to Avoid Them

Here are frequent errors users make when counting non-empty cells:

  • Using COUNTIF with “<>“ without the empty string: =COUNTIF(A:A,"<>") counts cells that are not equal to zero? Actually, that criteria counts all non-empty cells, including those with “”? No—"<>" means “not equal to nothing”, which is interpreted as “not blank”? In practice, COUNTIF(A:A,"<>") counts all non-empty cells, including those with formulas returning “”. It does not exclude “” because “” is not equal to a blank cell? Actually, it does count cells with “” because they are not blank. So to exclude “”, you must use "<>"&"".
  • Forgetting that spaces count: A cell with a space looks empty but is counted. Use TRIM if this matters.
  • Using COUNTBLANK and subtracting: You can count non-empty as =ROWS(A:A)-COUNTBLANK(A:A) but this fails if the range includes entire columns (infinite rows). Use a finite range like A1:A1000.
  • Mixing data types: COUNTA counts numbers, text, errors, and logicals. If you only want text or only numbers, use COUNTIF with specific criteria like "*" for text.

Comparing COUNTA, COUNTIF, and SUMPRODUCT

Here’s a quick comparison to help you choose:

  • COUNTA: Simplest, counts all non-blank cells including formulas returning “”. Best for quick counts when you don’t have such formulas.
  • COUNTIF with “<>“&””: Excludes cells with formulas returning “”, but still counts spaces. Good for most datasets.
  • SUMPRODUCT with TRIM: Excludes spaces and can handle multiple conditions. Use when data has stray spaces or you need complex criteria.

For example, if you have a column with 100 rows, 10 are truly blank, 5 have formulas returning “”, and 2 have spaces, then COUNTA returns 83 (100-10-5-2? Actually, it counts all non-blank: 100-10=90, but the 5 with “” are counted, and the 2 with spaces are counted, so 90? Wait, truly blank are 10, so non-blank are 90, but among those 90, 5 are “” and 2 are spaces, so COUNTA counts 90. COUNTIF with “<>“&”” counts 90-5=85 (excludes “” but includes spaces). SUMPRODUCT with TRIM counts 85-2=83 (excludes spaces too).

Frequently Asked Questions

How do I count non-empty cells in Google Sheets excluding formulas that return blank?
Use =COUNTIF(range,"<>"&""). This counts cells that are not equal to an empty string, so it ignores both truly empty cells and cells with formulas returning “”.

Why does COUNTA count cells with spaces?
Because a space is a character. COUNTA counts any cell that contains any value, including a single space. To exclude spaces, use =SUMPRODUCT((TRIM(range)<>"")*1).

Can I count non-empty cells in multiple columns at once?
Yes. Use =COUNTA(A1:C10) for a simple count, or =COUNTIF(A1:C10,"<>"&"") to exclude empty-string formulas. For per-row counts, use =BYROW(A1:C10, LAMBDA(row, COUNTA(row))).

What is the difference between COUNTIF and COUNTA for non-empty?
COUNTA counts all non-blank cells, including those with formulas returning “”. COUNTIF with criteria “<>“&”” excludes those formula-returned blanks. COUNTA is simpler but may overcount if you have such formulas.

How do I count cells that are not empty and also meet another condition?
Use =COUNTIFS(range1,"<>"&"", range2,"Yes") for multiple criteria, or =SUMPRODUCT((range1<>"")*(range2="Yes")) for more complex logic.

Does COUNTA count cells with errors like #N/A?
Yes, COUNTA counts error values because they are values. If you want to exclude errors, you can use =SUMPRODUCT((ISERROR(range)=FALSE)*(range<>"")), but that’s rarely needed.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.