If you want to learn how to count text in Excel, you need to use function COUNTIF with the criteria defined using wildcard *, with formula: `=COUNTIF(range;"*")`

. Range is defined cell range where you want to count the text in Excel and wildcard * is criteria for all text occurrences in the defined range.

Some interesting and very useful examples will be covered in this tutorial with main focus on COUNTIF function and different usages of this function in text counting. Limitations of COUNTIF function have been covered in this tutorial with additional explanation of other functions such as SUMPRODUCT/ISNUMBER/FIND functions combination. After this tutorial you will be able to count text cells in excel, count specific text cells, case sensitive text cells and text cells with multiple criteria defined – which is very good base for further creative Excel problem solving.** ** ** **

**1.** **Count Text Cells in Excel**

Text Cells can be easily found in Excel using COUNTIF or COUNTIFS functions. **COUNTIF** function, searches text cells based on specific criteria and in the defined range. As in example below, **defined range **is table Name list, and text** criteria** is defined using wildcard “*”. Formula result is 5, all text cells have been counted. Note that number formatted as text in cell B10 is also counted, but Booleans (TRUE /FALSE) and error (#N/A) are not recognized as text.

Formula for counting text cells:

`=COUNTIF(range;"*")`

For counting non text cells, formula should be a little bit changed in criteria part:

`=COUNTIF(range;"<>*")`

If there are several criteria for counting cells, then **COUNTIFS** function should be used. For example, if we want to count number of employees from Texas with project number greater than 20, then function will look like:

`=COUNTIFS(C3:C6;"Texas";D3:D6;">20").`

In **criteria range** in column State, a specific **text criteria** is defined under quotations “Texas”. The second criteria is numeric, **criteria range** is column Number of projects, and criteria is numeric value greater than 20, also under quotations “>20”. If we were looking for exact value, formula would look like:

`=COUNTIFS(C3:C6;"Texas";D3:D6;20)`

**2.** **Count Specific Text in Cells**

For counting specific text under cells range, COUNTIF function is suitable with formula:

`=COUNTIF(range;"*text*")`

`=COUNTIF(B3:B9;"*Mike*")`

First part of the formula is **range **and second is text **criteria,** in our example “*Mike*”. If wildcard ***** has not been used before and after criteria text, formula result would have been 1 (Formula would find cells only with word Mike). Wildcard *** **before and after criteria text, means that all cells that contain criteria characters will be taken into account. As in another example below with text criteria Sun, three cells were found (**sun**, **Sun**ny, **sun** is shining)

`=COUNTIF(B3:B10;"*Sun*")`

Note: COUNTIF function is not case sensitive, alternative function for case sensitive text searches is SUMPRODUCT/FIND function combination.

## 3. Count Case Sensitive Specific Text

For case sensitive text count, combination of three formulas should be used: **SUMPRODUCT, ISNUMBER and FIND**. Let look in the example below. If we want to count cells that contain text Sun, case sensitive, COUNTIF function would not be appropriate solution, instead of this function combination of three functions mentioned above has to be used.

`=SUMPRODUCT(--ISNUMBER(FIND("Sun";B3:B10)))`

We should go through separate function explanation in order to understand functions combination. **FIND function**, searches specific text in defined cell, and returns the number of the starting position of the text used as criteria. This explanation is relevant, if searching range is just one cell. If we want to use FIND function in a range of the cells, then combination with **SUMPRODUCT** function is necessary.

Without ISNUMBER, function combination of FIND and SUMPRODUCT functions would return error. ISNUMBER function is necessary because whenever FIND function does not match defined criteria, output will be error, as in print screen below of evaluated formula.

In order to change error values with Boolean TRUE/FALSE statement, **ISNUMERIC** formula should be used (defining numeric values as TRUE, and non-numeric as FALSE, as in print screen below).

You might be wondering what character **—** in** SUMPRODUCT **function stands for. It converts Boolean values TRUE/FALSE in numeric values 1/0, enabling SUMPRODUCT function to deal with numeric operations (without character — in** SUMPRODUCT **function, final result would be 0).

Remember, if you want to count specific text cells that are not case sensitive, COUNTIF function is suitable. For all case sensitive searches combination of SUMPRODUCT/ISNUMBER/FIND functions is appropriate.

**4. Count Text Cells with Multiple Criteria**

If you want to count cells with **Multiple criteria**, with all criteria acceptable, there is interesting way of solving that problem, combination of **SUMPRODUCT/ISNUMBER/FIND** functions. Please take a look in the example below. We should count all cells that contain either Mike or $. Tricky part could be the cells that contain both Mike and $.

`=SUMPRODUCT(--(ISNUMBER(FIND("Mike";B3:B11))+ISNUMBER(FIND("$";B3:B11))>0))`

Formula just looks complex, in order to be easier for understanding, I will divide it into several steps. Also, knowledge from previous tutorial point will be necessary for further work, since combination of FIND, ISNUMBER and SUMPRODUCT functions have been explained.

In first part of the function, we loop through the table and find cells that contain Mike:

`=ISNUMBER(FIND("Mike";B3:B11))`

Output of this part of the function will be array with values {1;0;0;0;1;0;0;0;1}, number 1, where criteria has been met, and 0, where has not.

In second part of the function, looping criteria is $, counting cells containing this value:

`=ISNUMBER(FIND("$";B3:B11))`

Output of this part of the function will be array with values {1;0;0;1;1;0;0;0;1}, number 1, where criteria has been met, and 0, where has not.

Next step is to sum these two arrays, since cell should be counted if any of conditions is fulfilled:

`=ISNUMBER(FIND("Mike";B3:B11))+ISNUMBER(FIND("$";B3:B11))`

Output of this step is {2;0;0;1;2;0;0;0;2}, number greater than 0 means that one of the condition has been met (2 – both conditions, 1 – one condition)

Without function part >0, final function would double count cells that met both conditions and final result would be 7 (sum of all array numbers). In order to avoid it, in formula should be added >0:

`=ISNUMBER(FIND("Mike";B3:B11))+ISNUMBER(FIND("$";B3:B11))>0`

Output of this step is array {1;0;0;1;1;0;0;0;1}, previous array has been checked and only values greater than 0 are TRUE (in array have value 1), and other are FALSE (in array have value 0).

Final output of the formula is sum of the final array values, 4.

Looks very confusing, but after several usages you will become familiar with this functions.

At the end we will cover one more multiple criteria text count function, already mentioned in tutorial, **COUNTIFS function.** In order to distinguish usage of functions mentioned above and COUNTIFS function, two words are enough OR/AND. If you want to count text cells with multiple criteria but all conditions have to be met at the same time, then COUNTIFS function is appropriate. If at least one condition should be met, then combination of function explained above is suitable.

Look at the example below, number of cells that contain both Mike and $ is easily calculated with COUNTIFS function:

`=COUNTIFS(range1;"*text1*";range2;"*text2*")`

`=COUNTIFS(B3:B11;"*Mike*";B3:B11;"*$*")`

In defined range, function counts only cells where both conditions have been met. Final result is 3.

## Leave a Comment