Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 668
steakpi Avatar asked Feb 07 '14 11:02

steakpi


People also ask

How do you count a cell if it contains any text Google Sheets?

=COUNTIF(A2:A13,"*mark*") This means that where this formula checks for the given condition, there could any number of characters/words before and after the criteria. In simple terms, if the word Mark (or whatever your criterion is) is present in the cell, this formula would count the cell.

How do I count the number of specific values in a column in Google Sheets?

You can use the =UNIQUE() and =COUNTIF() functions to count the number of occurrences of different values in a column in Google Sheets.

How do I count cells with text in Google Docs?

You can also use the COUNTIF function in Google Sheets to count cells with specific text. You can even modify it to count cells that do not contain a specific text. he formula will look like this =COUNTIF(range,”<>criterion”).

How do I count if a cell contains a text or number?

The Excel ISTEXT function returns TRUE when a cell contains a text value, and FALSE if the cell contains any other value. You can use the ISTEXT function to check if a cell contains a text value, or a numeric... The Excel NOT function returns the opposite of a given logical or Boolean value.


4 Answers

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.

like image 190
Stryder Avatar answered Nov 18 '22 02:11

Stryder


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.

like image 39
CalamitousCode Avatar answered Nov 18 '22 01:11

CalamitousCode


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
like image 41
rawnuggets Avatar answered Nov 18 '22 01:11

rawnuggets


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.

like image 41
pnuts Avatar answered Nov 18 '22 01:11

pnuts