Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sheets count how many cells contain a specific word / words?

I'm trying to look at all cells in a set of columns/cells to count how many of them contain the word WORDHERE (in this example)

I've tried using:

=SUM(COUNTIF(A1:A100, "WORDHERE"))

However this finds 0 as the cell contains other words/letters/numbers, if the cell only contains WORDHERE it works perfectly.

I've tried using several regeexxtract and regexmatch including the actual word as you can see below:

=SUM(COUNTIF(A1:A100,REGEXEXTRACT(A1:A100, "WORDHERE")))

But again, it finds 0 matches.

What am I doing wrong?

like image 946
Ryflex Avatar asked Nov 06 '16 04:11

Ryflex


People also ask

How do I count cells with specific text in Google Sheets?

We can use the COUNTIF Function to count the number of cells that contain specific text by using asterisk wildcards. Asterisk wildcards represent any number of any characters. By adding them before and after our text, we can count the number of cells where the text is found anywhere within the cell.

How do I count cells containing a specific word?

In the empty cell, type in the following: “ =COUNTIF (range, criteria) .” This formula counts the number of cells containing text inside your cell range.

How do I count occurrences of a word 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.


2 Answers

You don't need SUM around the COUNTIF.

=COUNTIF(A1:A100, "*WORDHERE*") 

will work just as fine. The same can indeed be achieved with regexmatch in a more complicated formula:

=sum(ArrayFormula(N(regexmatch(A7:A, "WORDHERE"))))

Here N-function is used to 'convert' the boolean values (TRUE or FALSE) to 1 or 0.

like image 84
JPV Avatar answered Oct 04 '22 19:10

JPV


Not exactly answering what you are doing wrong, but here is what you can do:

=COUNTIF(A1:A100, "*WORDHERE*")
like image 21
Jeremy Kahan Avatar answered Oct 04 '22 20:10

Jeremy Kahan