# How to count cells that are not blank in Google Sheets

URL: https://goingstellar.ro/reference/sheets/recipes/count-if-not-blank/

=COUNTA(A2:A6) is the shortest way to count non-blank cells, and =COUNTIF(A2:A6, "<>") gives the same count on the sample data. Both count a cell whose formula returns "" or that holds only a space, so use LEN when those must not count.

## Steps

1. Select the range to count and note its address, for example A2:A6.
2. Enter =COUNTA(A2:A6) for a fast count of filled cells.
3. Or use =COUNTIF(A2:A6, "<>"), which behaves the same on this data.
4. If formulas returning "" should count as blank, use =SUMPRODUCT(--(LEN(A2:A6)>0)).
5. If cells with only a space should count as blank too, wrap the range in TRIM inside LEN.
6. To count text cells with at least one character, ignoring numbers, try =COUNTIF(A2:A6, "?*"). A cell with a space counts as text.

## Examples

The examples use this table, starting in A1:

| Note |
|---|
| a |
|  |
| ="" |
|   |
| 7 |

```
=COUNTA(A2:A6)
```

Result: `4`

Counts every cell that is not truly empty: a, the empty-string formula, the space and 7. Result 4. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=COUNTIF(A2:A6, "<>")
```

Result: `4`

Same answer as COUNTA here: the empty-string formula still counts as filled. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SUMPRODUCT(--(LEN(A2:A6)>0))
```

Result: `3`

Counts cells with at least one character. The empty-string formula drops out, the space stays. Result 3. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SUMPRODUCT(--(LEN(TRIM(A2:A6))>0))
```

Result: `2`

TRIM also removes the space, so only a and 7 remain. Result 2. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=COUNTIF(A2:A6, "?*")
```

Result: `2`

Text with at least one character. The number 7 is not counted, but the space is. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- A formula that returns "" looks empty but COUNTA counts it. In the sample, A2:A4 holds a value, an empty cell and an empty-string formula, and COUNTA returns 2.
- A single space is content. COUNTA on a cell holding only a space returns 1, and TRIM inside LEN is needed to ignore it.
- COUNTIF with "" as criterion counts both the truly empty cell and the empty-string formula, so it is not a count of non-blank cells.

## Compared with Excel

COUNTA, COUNTIF, SUMPRODUCT, LEN and TRIM exist in Excel with the same syntax. The counts with empty text from formulas were measured in Google Sheets only.

## Functions used

- [COUNTA](https://goingstellar.ro/reference/sheets/counta/)
- [COUNTIF](https://goingstellar.ro/reference/sheets/countif/)
- [SUMPRODUCT](https://goingstellar.ro/reference/sheets/sumproduct/)
- [LEN](https://goingstellar.ro/reference/sheets/len/)
- [TRIM](https://goingstellar.ro/reference/sheets/trim/)

## Sources

- [COUNTA (Docs Editors Help)](https://support.google.com/docs/answer/3093991)
- [COUNTIF (Docs Editors Help)](https://support.google.com/docs/answer/3093480)
- [SUMPRODUCT (Docs Editors Help)](https://support.google.com/docs/answer/3094294)
- [LEN (Docs Editors Help)](https://support.google.com/docs/answer/3094081)

