How to count cells with text in Excel: any, specific, filtered cells

How do I count cells with text in Excel? There are a few different formulas to count cells that contain any text, specific characters or only filtered cells. All the formulas work in Excel 2019, 2016, 2013 and 2010.

Initially, Excel spreadsheets were designed to work with numbers. But these days we often use them to store and manipulate text too. Want to know how many cells with text there are in your worksheet? Microsoft Excel has several functions for this. Which one should you use? Well, it depends on the situation. In this tutorial, you will find a variety of formulas and when each formula is best to be used.

How to count number of cells with text in Excel

There are two basic formulas to find how many cells in a given range contain any text string or character.

COUNTIF formula to count all cells with text

When you wish to find the number of cells with text in Excel, the COUNTIF function with an asterisk in the criteria argument is the best and easiest solution:

COUNTIF(range, "*")

Because the asterisk (*) is a wildcard that matches any sequence of characters, the formula counts all cells that contain any text.

SUMPRODUCT formula to count cells with any text

Another way to get the number of cells containing text is to combine the SUMPRODUCT and ISTEXT functions:




The ISTEXT function checks if each cell in the specified range contains any text characters and returns an array of TRUE (cells with text) and FALSE (other cells) values. The double unary (--) or the multiplication operation coerces TRUE and FALSE into 1 and 0, respectively, producing an array of ones and zeros. The SUMPRODUCT function sums all the elements of the array and returns the number of 1's, which is the number of cells that contain text.

To gain more understanding of how these formulas work, please see which values are counted and which are not:

What is counted What is not counted
  • Cells with any text
  • Special characters
  • Numbers formatted as text
  • Visually blank cells that contain an empty string (""), apostrophe ('), space or non-printing characters
  • Numbers
  • Dates
  • Logical values of TRUE and FALSE
  • Errors
  • Blank cells

For example, to count cells with text in the range A2:A10, excluding numbers, dates, logical values, errors and blank cells, use one of these formulas:

=COUNTIF(A2:A10, "*")



The screenshot below shows the result:
Excel formula to count cells with text

Count cells with text excluding spaces and empty strings

The formulas discussed above count all cells that have any text characters in them. In some situations, however, that might be confusing because certain cells may only look empty but, in fact, contain characters invisible to the human eye such as empty strings, apostrophes, spaces, line breaks, etc. As a result, a visually blank cell gets counted by the formula causing a user to pull out their hair trying to figure out why :)

To exclude "false positive" blank cells from the count, use the COUNTIFS function with the "excluded" character in the second criterion.

For example, to count cells with text in the range A2:A7 ignoring those that contain a space character, use this formula:

=COUNTIFS(A2:A7,"*", A2:A7, "<> ")

Formula to count cells with text excluding cells that contain spaces

If your target range contains any formula-driven data, some of the formulas may result in an empty string (""). To ignore cells with empty strings too, replace "*" with "*?*" in the criteria1 argument:

=COUNTIFS(A2:A9,"*?*", A2:A9, "<> ")

A question mark surrounded by asterisks indicates that there should be at least one text character in the cell. Since an empty string has no characters in it, it does not meet the criteria and is not counted. Blank cells that begin with an apostrophe (') are not counted either.

In the screenshot below, there is a space in A7, an apostrophe in A8 and an empty string (="") in A9. Our formula leaves out all those cells and returns a text-cells count of 3:
Count cells with text excluding spaces and empty strings

How to count cells with certain text in Excel

To get the number of cells that contain certain text or character, you simply supply that text in the criteria argument of the COUNTIF function. The below examples explain the nuances.

To match the sample text exactly, enter the full text enclosed in quotation marks:

COUNTIF(range, "text")

To count cells with partial match, place the text between two asterisks, which represent any number of characters before and after the text:

COUNTIF(range, "*text*")

For example, to find how many cells in the range A2:A7 contain exactly the word "bananas", use this formula:

=COUNTIF(A2:A7, "bananas")

To count all cells that contain "bananas" as part of their contents in any position, use this one:

=COUNTIF(A2:A7, "*bananas*")

To make the formula more user-friendly, you can place the criteria in a predefined cell, say D2, and put the cell reference in the second argument:


Depending on the input in D2, the formula can match the sample text fully or partially:

  • For full match, type the whole word or phrase as it appears in the source table, e.g. Bananas.
  • For partial match, type the sample text surrounded by the wildcard characters, like *Bananas*.

As the formula is case-insensitive, you may not bother about the letter case, meaning that *bananas* will do as well.
Formulas to count cells that contain certain text – exact and partial match

Alternatively, to count cells with partial match, concatenate the cell reference and wildcard characters like:

=COUNTIF(A2:A7, "*"&D2&"*")

Formula to count cells with certain text in Excel

For more information, please see How to count cells with specific text in Excel.

How to count filtered cells with text in Excel

When using Excel filter to display only the data relevant at a given moment, you may sometimes need to count visible cells with text. Regrettably, there is no one-click solution for this task, but the below example will comfortably walk you through the steps.

Supposing, you have a table like shown in the image below. Some entries were pulled from a larger database using formulas, and various errors occurred along the way. You are looking to find the total number of items in column A. With all the rows visible, the COUNTIF formula that we've used for counting cells with text works a treat:

=COUNTIF(A2:A10, "*")

And now, you narrow down the list by some criteria, say filter out the items with quantity greater than 10. The question is – how many items remained?
Filtered cells with text that need to be counted

To count filtered cells with text, this is what you need to do:

  1. In your source table, make all the rows visible. For this, clear all filters and unhide hidden rows.
  2. Add a helper column with the SUBTOTAL formula that indicates if a row is filtered or not.
    To handle filtered cells, use 3 for the function_num argument:

    =SUBTOTAL(3, A2)

    To identify all hidden cells, filtered out and hidden manually, put 103 in function_num:

    =SUBTOTAL(103, A2)

    In this example, we want to count only visible cells with text regardless of how other cells were hidden, so we enter the second formula in A2 and copy it down to A10.

    For visible cells, the formula returns 1. As soon as you filter out or manually hide some rows, the formula will return 0 for them. (You won't see those zeros because they are returned for hidden rows. To make sure it works this way, just copy the contents of a hidden cell with the Subtotal formula to any visible say, say =D2, assuming row 2 is hidden.)

    Identifying visible cells

  3. Use the COUNTIFS function with two different criteria_range/criteria pairs to count visible cells with text:
    • Criteria1 - searches for cells with any text ("*") in the range A2:A10.
    • Criteria2 - searches for 1 in the range D2:D10 to detect visible cells.

    =COUNTIFS(A2:A10, "*", D2:D10, 1)

Now, you can filter the data the way you want, and the formula will tell you how many filtered cells in column A contain text (3 in our case):
Excel formula to count filtered cells with text

If you'd rather not insert an additional column in your worksheet, then you will need a longer formula to accomplish the task. Just choose the one you like better:


=SUMPRODUCT(SUBTOTAL(103, OFFSET(A2:A10, ROW(A2:A10) - MIN(ROW(A2:A10)),,1)), -- (ISTEXT(A2:A10)))

The multiplication operator will work as well:


=SUMPRODUCT(SUBTOTAL(103, OFFSET(A2:A10, ROW(A2:A10)-MIN(ROW(A2:A10)),,1)) * (ISTEXT(A2:A10)))

Which formula to use is a matter of your personal preference - the result will be the same in any case:
Formula to count visible cells with text

How these formulas work

The first formula employs the INDIRECT function to "feed" the individual references of all cells in the specified range to SUBTOTAL. The second formula uses a combination of the OFFSET, ROW and MIN functions for the same purpose.

The SUBTOTAL function returns an array of 1's and 0's where ones represent visible cells and zeros match hidden cells (like the helper column above).

The ISTEXT function checks each cell in A2:A10 and returns TRUE if a cell contains text, FALSE otherwise. The double unary operator (--) coerces the TRUE and FALSE values into 1's and 0's. At this point, the formula looks as follows:

=SUMPRODUCT({0;1;1;1;0;1;1;0;0}, {1;1;1;0;1;1;0;1;1})

The SUMPRODUCT function first multiplies the elements of both arrays in the same positions and then sums the resulting array.

As multiplying by zero gives zero, only the cells represented by 1 in both arrays have 1 in the final array.


And the number of 1's in the above array is the number of visible cells that contain text.

That's how to how to count cells with text in Excel. I thank you for reading and hope to see you on our blog next week!

Available downloads

Excel formulas to count cells with text

You may also be interested in

51 responses to "How to count cells with text in Excel: any, specific, filtered cells"

  1. Talal says:

    I have row of duty roaster which contains DO RD, and I wanted to count number of DO till just it change to RD then count the number RD till just change to OD then again counting the remaining ODs for the rest of the month.
    I can sen you my time sheet for clearer info.

  2. J. Merry says:

    Good Day Sir,
    My question is this. I have a list of all "Fruits" in column A. Those "Fruits" count for many row entries each. I would like to count how many rows each "Fruit" totals to. Lets say I have "Apple" 50 times, "Banana" 20 Times and each "Fruit" has a different number of appearances and there are a LOT of different "Fruit". My goal is to create a list of how many times the "Fruit" shows on my spreadsheet in a certain Column and output a count by Type of "Fruit". So I get a list of How many times "Apple" shows or "Banana" Shows.

  3. zech says:

    hi. Need help.
    I have a row of numbers and text "IN" (in different cells).
    What formula do I use to count the total if any of the cells in the row have numbers and IN.
    Thank you in advance

  4. Seven says:

    hello sir,
    i have a 03 criterias (higher,lower and standard)in a column which ranges from (8-34200 rows)i also have date column now my problem is whenever i makes a filter in date for example if i want to check how many higher ,lower cases are occured on particular date

  5. Hudson says:

    Is there a formula that will count all cells containing text within a specific range except cells that contain certain a certain word or character (in my case, I need a count that includes everything in the spreadsheet except blank cells and cells that contain "X"). Thank you!

  6. Joetta says:

    Im looking for a formula to give me only the number of managers I have working projects. Each manager has multiple projects they work on. Manager names are in column A. Projects in B. I only want to know the total managers I have, not the projects I have. For instance, John's name is listed 8 times, Mike's name is listed 6 and Jill's name is listed 7 times. The answer I want is 3.

  7. Matt Sherry says:

    Hello, I'm trying to get a row to tally if a range has either P,S, or 2 within the range. Is there a way to accomplish this?

    • Hello!
      I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. Please specify what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  8. Robert says:

    Hi Team

    I have been battling for ages to get this formula right,

    =COUNTIF('Day 1:Day 31'!J8:J25,"CORGI")

    I have a 12 mth workbook with and column J8:j25 that has names in text ie Corgi,Sandra,Stuart,House etc.

    i can use the countif to find the individual totals on a single work sheet but that takes up a lot of time and space , i am looking the formula to use on a summary sheet and this is the best thing i have come up with but does not work, for some reason the J8:j25 just relates to the summary sheet i iam working on.

    could you please shed some light on where i am going wrong?

    Many thanks

  9. Marisa says:

    I have attendance sheet to prepare so I want to count number of p in the same row from 1st September to 30th September. how do I do it?

  10. JACK says:


  11. Lynne says:

    I have a column with various names and another column with various statuses attached to those names. I want to distinguish specific statuses attached to these names.
    E. G.
    Column A and B will look like this:
    Mr A. Status complete
    Mr A. Status outstanding
    Mr A status paid
    MR B status outstanding
    MR B status complete

    I need to which of these rows per name contain a combination of statuses complete and paid.
    In example above Mr A must be shown to have a status in 2 of the rows and Mr B will not show up anything.
    How do I go about this?

  12. Eddie says:

    Hi, I have a sheet which I'm using to calculate how many sales are from which or 10 companies. Column B has customers names, column aa has the main company name, column aj is closed (not sold) and column ao has the dates something was sold. I have a table on a separate tab with this formula: =COUNTIF(Main!AA:AA,A2) main is the tab name, AA the column and A2 is the cell with the company name I'd like to count. My question is, what formula what I use if I wanted to count these names only if sold (based on any text in column ao), closed (based on any text in column aj) and still outstanding based on no text in ao or aj. Hopefully that makes sense! Thanks

    • Eddie says:

      ps. I should point out that I'm counting the number of cells, not the value within those cells as they all contain text or dates. But if it is also possible to count the value of columns AL, AM, and AN based on the company name in column AA, then that would be amazing.

  13. ClaraMaricela Topete says:

    Hey there
    I have a sheet that in column B has the location (ex, Cali/ Texas) and the column D - I tally all the ones from Cali aka California and Column E - I tally all the ones from Texas
    Col B Col D Col E
    Cali 1
    Texas 1
    - My question is, is there a way to have column D auto generate a "1" when column B states Cali and vise versa for column E auto generate a "1" when column B states Texas.

  14. Ana says:

    From the example of =COUNTIF(A2:A7, "bananas")
    What formula would I use to have that same row count BANANAS and APPLES at the same time.

    thank you in advance.

  15. Asif says:

    Need some help Please
    let say i have 4 sheet name (A,B,C & D)
    it is actually days shift report , mean same format but different fault log of equipments.
    let say there are 4 equipments ( Eq-1,Eq-2,Eq-3 & Eq-4) in one colum and second colum has its different fault types like( brake fault, hoist fault, run fault etc..)
    same fault log could be in all sheets (A,B,C & D).
    now on one sheet say summary i want to count Eq-1 brake fault what how many time it occurs total in all 4 sheets.
    i hope i have explained details about my requirement.
    Please help me.


  16. RAMON TORRES says:

    A lot of useful information,

    Thank you,

  17. RAMON TORRES says:

    Is there any why to use SUBTOTAL with COUNTIF?
    I would like to count cells with text from a filtered list of text.
    I know how to do this with adding numbers but not counting text.

    Thank you,

  18. Trish says:

    I may have missed this in your above info, but how do I count a row of 'text' that contains both dates and text? I am trying to get a subtotal of tasks undertaken by a list of clients.

  19. Ivan says:


    I have a table with 10 columns and 240 rows. Every cell contains a product in text format. Is there any formula to count the total number of every product in the whole table without putting any criteria for searching any product. Because the products are more than 100.


    • Hello!
      Give an example of the source data and the expected result. Do you want to get a list of all products along with the quantity of each product? For this I recommend using a pivot table. If this is not what you wanted, please explain the problem in more detail.

      • Ivan says:

        By using a pivot table I can count column by column. I want to count the numbers from all columns automatically without specifying a criteria for each product. Here is the example:

        Database Final table

        A B D F G A number
        B C A I H B number
        C A B L A C number
        E F G C A D number
        K I H E F E number
        L A M A I F number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number
        …. …. …. …. …. … number

      • Ivan says:

        It's not visible. Now I think it's better.


        A B D F G
        B C A I H
        C A B L A
        E F G C A
        K I H E F
        L A M A I
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….
        …. …. …. …. ….

        Final table

        A number
        B number
        C number
        D number
        E number
        F number
        … number
        … number
        … number

        • Hello!
          Use this formula to extract unique values from a range.
          Assuming your values ​​are in the range A2: C9, enter the following formula in cell E2:

          =INDIRECT(TEXT(MIN(IF(($A$2:$C$9<>"") * (COUNTIF($E$1:E1,$A$2:$C$9)=0), ROW($2:$9)*100+COLUMN($A:$C),7^8)),"R0C00"),)&""

          In the above formula, A2:C9 indicates the range of cells from which you want to extract unique values. E1 is the first cell in the column where you want to place the result. $2:$9 means strings containing cells you want to use. $A:$C points to the columns containing the cells you want to use. Please change them to your own.
          Press Shift + Ctrl + Enter and then drag the fill handle to extract unique values ​​until blank cells appear.

          To count the number of each unique value in a range use the formula


          I hope I answered your question. If something is still unclear, please feel free to ask.

  20. Sadiyah says:

    I was wondering if there is a way to count the total number of entries for one certain type of information, I have a spreadsheet with over 500 entries but I need to know the total entries for one particular key word

    hope this makes sense

    please advise

    thank you

  21. Cindi says:

    I have a spreadsheet that has a column for each month (12 columns) and a row for each day (31 rows), I have put in each column and row a letter to track type of days off, I want to total the types of days off on a separate spreadsheet. Is there a formula that will do this for me?

Post a comment

Thank you for your comment! When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to your query. We cannot guarantee that we will answer every question, but we'll do our best :)