見出し画像

Cool! How to count the number of English words with Excel functions.

Excel has a function called LEN function that can be used to count the number of characters. If the original text is in Japanese or Chinese, the LEN function can be used to count the number of characters as it is. However, if you want to count the number of words in English or French, the LEN function cannot be used as it is. There seems to be no function that directly counts English words.

Now we are in trouble.
Yet, it is possible to count the number of English words by adding a little twist to the LEN function.

In fact, I usually work as a PM for a translation company. I often come up with small tricks and tricks to handle text processing.

Back to the main topic: we wanted to use the LEN function in Excel to count the number of words.

Let's start with the principle.
For example, suppose there is an English sentence, "Thank you very much.”
The number of words should be 4, but the LEN function counts it as 20. This is because the LEN function counts the number of characters including spaces. The following figure shows the result.


So how can we count words? Let's take a closer look at the previous figure.

 Do you notice something here? Yes, there is always a space after a word in English.

However, the number of words does not equal the number of spaces. Here, the number of spaces is 3, which is one less than the number of words.

We may also see the relationship between the number of spaces (3) and the number of words (4) by adding 1 to the number of spaces (3).

If this could be represented by an Excel function, it would be possible to count the number of words in an Excel cell.

Since Excel does not have a function to count the number of spaces, we need to devise a way to extract the number of spaces. Once the number of spaces is extracted, the number of words can be obtained by adding 1 to the number of spaces.

Let me show you the procedure.

STEP 1.
Count including spaces with LEN function---put it as N


STEP 2. 
Replace space with no space by SUBSTITUTE function--- put it as n

 
STEP3. 
N-n. and the number of spaces remains, so add 1 to get the number of words.
 

単語数 means the number of words


Now it is the time to make a formula using an Excel function, like this:
=LEN(B3)-LEN(SUBSTITUTE(B3," ",""))+1

文字数 means number of letters

I`d like you to think that "Thank you very much." is in the third column of column B of the Excel file.
 
The following is a processed version of what I actually used for management in my work. The text is reduced in size for display in this image.
 


For me, the idea of using the simple fact of the relationship between the number of letters and the number of spaces as a formula for extracting words is cool.

I hope this was helpful to you all.


この記事が気に入ったらサポートをしてみませんか?