fbpx

How to count text in Excel?

Imagine your team members have entered all their project hours in a worksheet and you need to count it.

In other words, you also need to count the cells that have data. To complicate matters, the data may not be numeric. Some of your team members may have entered placeholder values such as “TBD”.

So can you count it in a simple way?!

Yes, You can count it using COUNTA Function!

Microsoft Excel has a handful of useful functions that can count nearly everything. The COUNT function is to count cells with numbers, COUNTA to count non-blank cells, COUNTIF and COUNTIFS to conditionally count cells and LEN to calculate the length of a text string.

Unfortunately, Excel doesn’t provide any built-in tool for counting the number of words. Luckily, by combining serval functions you can make more complex formulas to accomplish almost any task. And we will be using this approach to count words in Excel.

Now let’s go through the following steps to count text in Excel!

Let’s Count cells that are not blank


Calculate Results in Excel

 

Step 1: We need to count a total number of cells which are not blank in the range of B2:E6.

to type formula for counting total present of students

Step 2: We are going to use cell B8 to type formula for counting total present of students. As we want to count it from the range of B2:E6, So type this formula in cell B8:

=COUNTA(B2:E6)


Now press ENTER. The result is showing 17. So our counting is done!
In this way we can count more than one range cells using Comma separated ranges inside COUNTA function.
Read More: How to unlock scroll lock in Excel?

Tips: If we need to count from two different ranges like above picture, just change the formula like given below:

  =COUNTA(B2:C6,F2:G6)

In this way, we can count more than one range cells using Comma separated ranges inside COUNTA function.

How to count the total number of words in a cell

How to count the total number of words in a cell

Now we will learn how to count the total number of word in a particular cell using LEN, SUBSTITUTE and TRIM functions

Step 3: Create another Sheet and Input a sentence in Cell A1 like above picture. To count words in cell A1, use this formula in cell B1:

  =LEN(TRIM(A1))-LEN(SUBSTITUTE(A1,” “,””))+1

Now press ENTER. It is showing the result 7. So there are 7 words in cell A1.


Remember: How this word counting formula works?

=LEN(TRIM(A1))-LEN(SUBSTITUTE(A1,” “,””))+1

First, we use the SUBSTITUTE function to remove all spaces in the cell A1 by replacing them with an empty text string (“”) for the LEN function to return the length of the string without spaces:

LEN(SUBSTITUTE(A1,” “,””))

After that, we subtract the string length without spaces from the total length of the string and add 1 to the final word count, since the number of words in a cell equals to the number of spaces plus 1.

Additionally, we use the TRIM function to eliminate extra spaces in the cell, if any. Sometimes a worksheet may contain a lot of invisible spaces, for example, two or more spaces between words or space characters accidentally typed at the beginning or end of the text (i.e. leading and trailing spaces). All those extra spaces can throw your word count off. To guard against this, before calculating the total length of the string, we use the TRIM function to remove all excess spaces except for single spaces between words.

So, now we have learned how to count text in Excel! Enjoy Excel!