In this article:

Count Cells with Specific Text in Google Sheets (The Easy Way!)

May 8, 2024

After learning how COUNTIF works in Google Sheets, you will find that there are numerous possibilities. 

In this article you will learn more how to use the COUNTIF to tally how frequently a string appears in the sheet.

Are you ready?

Count Cells with a Specific Text using the COUNTIF Function

Syntax

=COUNTIF(range,”text”)

Where

text is the text you are looking for

range is where you want to look for the text

Step 1: Identify the text and range

We want to count cities of Florida in our list of cities with their corresponding states. The range is C2:C101 and the text is “Florida”.

Google Sheets, range selected

Step 2: Select the cell, then add the formula with the format =COUNTIF(range,”text”)

The formula will now be 

=countif(C2:C101,"Florida")

Google Sheets count cells that contain a specific text

That’s it! You can now tally cells with a certain text using COUNTIF. Let us apply it to more cases.

Count Number of Cells that DO NOT Contain a Specific Text

Syntax

=COUNTIF(range,”<>text”)

Where

text is the text you want to exclude

range is where you want to look for the text

The <> symbol means not equal.

Step 1: Identify the text and range

We want to tally cities that are not in California. The range is C2:C101 and the text is “<>California”.

Google Sheets, range selected

Step 2: Select the cell, then add the formula with the format =COUNTIF(range,”text”)

The formula will now be 

=countif(C2:C101,"<>California")

Google Sheets count cells that do not contain a specific text

Count number of Cells that Contain a Portion of a String

Wildcard symbols tell Google Sheets that a set of characters precede or follow a given string. We use asterisk * as it means the preceding or following characters have varying lengths. 

Syntax

When you know the first part of the text

=COUNTIF(range,”string*”)

When you know the last part of the text

=COUNTIF(range,”*string”)

When you know the middle part of the text

=COUNTIF(range,”*string*”)

This will also count cases where the string appears at the start or at the end.

Step 1: Identify the text and range

We want to count cities whose states they belong to have the string “ia” in their name: at the beginning, in the middle, and at the end of their names. The range is C2:C101 and the string for each case are:

“ia*” for cells with “ia” at the start

“*ia*” for cells with “ia” at the middle

“*ia” for cells with “ia” at the end

Google Sheets, range selected

Step 2: Select the cell, then add the formula with the format =COUNTIF(range,”text”)

Google Sheets count cells that contain a string portion

See? It’s straightforward!

Count Cells with 2 or More Given Texts using the COUNTIF Function

You can determine how frequently two or more given texts appear in the selected range by making a combination of COUNTIF with ARRAYFORMULA and SUM functions.

Syntax

=ARRAYFORMULA(SUM(COUNTIF(range,{”text1”,”text2”})))

Where

text1 and text2 are the strings you are tallying

range is where you want to look for text1 and text2

Step 1: Identify the text and range

We want to count cities that are located in Texas and Florida. The range is C2:C101, and text1 and text2 are “Texas” and “Florida”, respectively.

Google Sheets, range selected

Step 2: Select the cell, then add the formula with the format =ARRAYFORMULA(SUM(COUNTIF(range,{”text1”,”text2”})))

For our example, the formula will be

=arrayformula(sum(countif(C2:C101,{"Florida","Texas"})))

Count if cell contains given text google sheets, find instances of cells that has two or more texts

FAQs

Can the string be stored in another cell?

Yes! It’s generally straightforward to do so. The syntax is 

=COUNTIF(range, cell_containing_text)

Where

cell_containing_text is the reference to the cell containing the text 

range is where you want to look for the text

The difference here is that the text stored in another cell no longer needs to be enclosed in double quotes.

Google Sheets count text with string stored in another cell

For counting the number of cells that do not contain a certain text, you need to use CONCATENATE function:

=COUNTIF(range,CONCATENATE(“<>”,cell_containing_text)

Google Sheets count text with strings stored in another cell

Can I count unique values?

Sure you can! Check out our tutorial to count unique values in Google Sheets.

If you enjoyed this article, you might also like our article on how to count checkboxes in Google Sheets or our article on how to sort on Google Sheets

If you want to learn how to attach Google Sheets to email, we also suggest checking out our detailed guide. 

Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->