Count number of cells with any value (string or number) in a column in Google Docs Spreadsheet

Google SheetsGoogle Docs

Google Sheets Problem Overview


I have several columns in Google Spreadsheet.

I would like to count how many cells have a value (number or string) and display that number at the top of the column.

For example:


Hello
World
123
Some string

The above column would give me the answer of "4"

I have not managed to find a formula that does this.

Google Sheets Solutions


Solution 1 - Google Sheets

In the cell you want your result to appear, use the following formula:

=COUNTIF(A1:A200,"<>")

That will count all cells which have a value and ignore all empty cells in the range of A1 to A200.

Solution 2 - Google Sheets

You could also use =COUNTA(A1:A200) which requires no conditions.

From Google Support: > COUNTA counts all values in a dataset, including those which appear > more than once and text values (including zero-length strings and > whitespace). To count unique values, use COUNTUNIQUE.

Solution 3 - Google Sheets

An additional trick beside using =COUNTIF(...) and =COUNTA(...) is:

=COUNTBLANK(A2:C100)

That will count all the empty cells.

This is useful for:

  • empty cells that doesn't contain data
  • formula that return blank or null
  • survey with missing answer fields which can be used for diff criterias

Solution 4 - Google Sheets

Shorter and dealing with a column (entire, not just a section of a column):

=COUNTA(A:A)

COUNTA

Beware, a cell containing just a space would be included in the count.

Solution 5 - Google Sheets

The SUBTOTAL function can be used if you want to get the count respecting any filters you use on the page.

=SUBTOTAL(103, A1:A200)

will help you get count of non-empty rows, respecting filters.

103 - is similar to COUNTA, but ignores empty rows and also respects filters.

Reference : SUBTOTAL function

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsteakpiView Question on Stackoverflow
Solution 1 - Google SheetsStryderView Answer on Stackoverflow
Solution 2 - Google SheetsCalamitousCodeView Answer on Stackoverflow
Solution 3 - Google SheetsrawnuggetsView Answer on Stackoverflow
Solution 4 - Google SheetspnutsView Answer on Stackoverflow
Solution 5 - Google Sheetssaji89View Answer on Stackoverflow