How to Count Cells that Contain Text Strings

Watch Video – How to Count Cells that Contain Text Strings

Counting is one of the most common tasks people do in Excel. It’s one of the metric that is often used to summarize the data.

For example, count sales done by Bob, or sales more than 500K or quantity of Product X sold.

Excel has a variety of count functions, and in most cases, these inbuilt Excel functions would suffice. Below are the count functions in Excel:

  • COUNT – To count the number of cells that have numbers in it.
  • COUNTA – To count the number of cells that are not empty.
  • COUNTBLANK – To count blank cell.
  • COUNTIF/COUNTIFS – To count cells when the specified criteria are met.

There may sometimes be situations where you need to create a combination of functions to get the counting done in Excel.

One such case is to count cells that contain text strings.

Count Cells that Contain Text in Excel

Text values can come in many forms. It could be:

  • Text String
    • Text Strings or Alphanumeric characters. Example – Trump Excel or Trump Excel 123.
  • Empty String
    • A cell that looks blank but contains =”” or ‘ (if you just type an apostrophe in a cell, it looks blank).
  • Logical Values
    • Example – TRUE and FALSE.
  • Special characters
    • Example – @, !, $ %.

Have a look at the data set shown below:

Count Cells that Contain Text in Excel Data Set

It has all the combinations of text, numbers, blank, special characters, and logical values.

To count cells that contain text values, we will use the wildcard characters:

  • Asterisk (*): An asterisk represents any number of characters in excel. For example, ex* could mean excel, excels, example, expert, etc.
  • Question Mark (?): A question mark represents one single character. For example, Tr?mp could mean Trump or Tramp.
  • Tilde (~): To identify wildcard characters in a string.
See Also: Examples of using Wildcard Characters in Excel.

Now let’s create formulas to count different combinations.

Count Cells that Contain Text in Excel (including Blanks)

Here is the formula:

=COUNTIF(A1:A11,”*”)

This formula uses COUNTIF function with a wildcard character in the criteria. Since asterisk (*) represents any number of characters, it counts all the cells that have text characters in it.

It even counts cells that have an empty string in it (an empty string can be a result of formula returning =”” or a cell that contains an apostrophe). While a cell with empty string looks blank, it is counted by this formula.

Logical Values are not counted.

Count Cells that Contain Text in Excel Text with blanks

Also read: Check IF Cell Contains Partial Text in Excel

Count Cells that Contain Text in Excel (excluding Blanks)

Here is the formula:

=COUNTIF(A1:A11,"?*")

In this formula, the criteria argument is made up of a combination of two wildcard characters (question mark and asterisk).

This means that there should, at least, be one character in the cell.

This formula does not count cells that contain an empty string (an apostrophe or =””). Since an empty string has no character in it, it fails the criteria and is not counted.

Logical Values are also not counted.

Count Cells that Contain Text in Excel Text without blanks

Count Cells that Contain Text (excluding Blanks, including Logical Values)

Here is the formula:

=COUNTIF(A1:A11,"?*") + SUMPRODUCT(--(ISLOGICAL(A1:A11))

The first part of the formula uses a combination of wildcard characters (* and ?). This returns the number of cells that have at least one text character in it (counts text and special characters, but does not count cells with empty strings).

The second part of the formula checks for logical values. Excel ISLOGICAL function returns TRUE if there is a logical value and FALSE if there isn’t.

A double negative sign ensures that TRUEs are converted into 1 and FALSEs into 0. Excel SUMPRODUCT function then simply returns the number of cells that have a logical value in it.

Count Cells that Contain Text in Excel Text with Logical Values

These above examples demonstrate how to use a combination of formulas and wildcard characters to count cells. In a similar fashion, you can also construct formulas to find the SUM or AVERAGE of a range of cells based on the data type in it.

You May Also Like the Following Excel Tutorials:

Excel Ebook Subscribe

FREE EXCEL BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Sumit Bansal
Hello there! I'm Sumit Bansal, founder of trumpexcel.com and an Excel MVP. I started this website in 2013 with a simple goal: to share my love for Excel through easy to follow tips, tutorials and videos. I'm here to help you get the best out of MS Excel to save time and boost your productivity.

4 thoughts on “How to Count Cells that Contain Text Strings”

  1. Countif formula not working if need to count selected keyword like | within string.

    ID_code|Tran_date|Type_tran|Amount_Bill_| _ |
    =COUNTIF(P17,”*|”)

    Reply
  2. Thank you Sumit, You are a great teacher.. and your tutorial notes and video are well
    documented. I have certainly learnt something new today. Thank you for sharing….Cathy

    Reply

Leave a Comment

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free Excel Tips EBook Sumit Bansal

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster