How to Use LEN Function in Google Sheets (4 Practical Examples)

The Google Sheets make your work easier by developing some very handy functions. The LEN function is one of them. This function will help you to count the number of characters in your dataset and can be more efficient while combine with other functions. This article will explain the Google Sheets LEN function with examples.

overview of len function in google sheets


A Sample of Practice Spreadsheet

You can download spreadsheets from here and practice.


What Is LEN Function in Google Sheets?

The LEN function is a basic text function that returns the number of character input in it as a parameter.

Syntax

The following is the syntax for the LEN function:

=LEN(text)

syntax of len function

Argument

The arguments of the LEN function are as follows:

ARGUMENT REQUIREMENT FUNCTION
text Required The string whose length will be returned.

Output

The function =LEN(“Mariah”) returns with the number 6. As the word contains six characters. A cell reference can also be used instead of the text.

Note: It counts all types of values like letters, numbers, special characters, space.

4 Practical Examples of Using the LEN function in Google Sheets

The use of the LEN function is quite simple and straight. You can use this function in many ways by modifying it with other functions. We will show all these examples of using the LEN function. Here, we create a dataset representing Greeting Signs. We add another column to show the results.

dataset of len function in google sheets


1. Characters in a Cell Count

You can easily count a cell’s length through the LEN function. But the LEN function always counts all the characters of a certain cell. In that case, it also counts the space. So, here we show both with-space and without-space count methods.

1.1 With Space

To calculate character with space,

  • First, Select cell C5 to insert the function.

select cell in google sheets

  • Then insert the LEN formula.

insert len function in google sheets

  • After that add the text. Here, we add cell B5 as the text parameter.

add text parameter for the function

  • Finally, press ENTER and you will find the total number of characters in the selected cells.
=LEN(B5)

output of len function in google sheets

  • Instead of cell reference, you can directly insert text to run the function. Here, we insert “Good Morning!”.
=LEN(“Good Morning”)

output of len function in google sheets

  • Use the fill handle to input the formula to the entire column.

use fill handle to insert function


1.2 Without Space

If you want to count only the value, not the space then,

  • First, select cell D5 and insert the LEN formula.

insert len function in google sheets

combine with substitute function

  • Now, select cell B5 as text_to_search parameter.

add search value in function

  • As we search for space so input “ “ as the search_for argument.

insert value in the function

  • In the end, insert “” as replace_with parameter.

add argument for the function

  • Finally, press ENTER to run the function and you will find only the value number excluding space.
=LEN(SUBSTITUTE(B5,” “,””))

outcome of len function in google sheets

  • Use the fill handle to insert the formula into the entire column.

use fill handle to fill the column


2. Count Characters in a Range of Cells

You can use this LEN function to count characters for a range of data. In this case, you also determine characters both including and excluding space value. To show this example we marge the result cells.

modify dataset for len function for range

2.1 Include Space

To count a range of values including space,

apply sumproduct function in google sheets

  • Then insert the LEN formula.

insert len function in google sheets

  • Now add the range you want to count. Here, we insert B5:B9 to count characters.

add range as text

  • To apply the function press, ENTER.
=SUMPRODUCT(LEN(B5:B9))

outcome of len function in range


2.2 Do Not Include Space

If you want to see the number of values excluding space in a range of data, then you have to combine several basic functions along with the LEN function.

  • In the beginning, select the cell and add the SUMPRODUCT function.

insert sumproduct function in google sheets

  • Then insert the LEN formula.

insert len function in google sheets

  • After that add the SUBSTITUTE function.

add substitute function to replace space

  • Now, select range B5:B9 as text_to_search parameter.

add search value parameter

  • Insert blank space or “ “ as search_for argument.

insert space in funcrtion

  • In the end, add “” as replace_with parameter.

replace space through replace with argument

  • Finally, press ENTER to run the formula.
=SUMPRODUCT(LEN(SUBSTITUTE(B5:B9,” “,””)))

outcome of len function in without space range


3. Words Count

To work with Google Sheets most often we need to count the number of words. Though the LEN function determines the length of the text, it can’t count the number of words. But luckily customizing the LEN formula with other functions you can easily count the words in your dataset.

To show the example,

  • First Select cell C5 and insert the LEN function.

insert len function in google sheets

apply trim function

  • Now, add the B5 cell as text.

input text argument

  • Insert the “-” symbol and again add the LEN function.

insert len function in google sheets

  • After that, input the SUBSTITUTE function. Where we select the B5 cell as text_to_search parameter, “ “ is search_for argument and “” is replace_with parameter.

apply substitute function

  • In the end, add the “+” symbol and then put 1.

add value in the function

  • Finally, to run the formula press ENTER and you will find the word count in the selected cell.
=LEN(TRIM(B5))-LEN(SUBSTITUTE((B5),” “,””)) + 1

outcome of the len function for words

Formula Breakdown

  • The TRIM function removes space before and after the sentence. So, LEN(TRIM(B5)) counts the character of the sentence in cell B5 with space between words.
  • The SUBSTITUTE function finds and removes space between words in the sentence. So, LEN(SUBSTITUTE((B5),” “,””) represents the total number of characters without any space.
  • LEN(TRIM(text))-LEN(SUBSTITUTE((B5),” “,””)) will determine the total space between words.
  • 1 is added to count the space before the first word.
  • =LEN(TRIM(B5))-LEN(SUBSTITUTE((B5),” “,””)) + 1 represents the number of words.
  • You can use the fill handle to insert the formula into the entire column.

use fill handle to insert len function in google sheets


4. Counting Specific Character

Like the previous example, you can count any specific character by customizing the formula. To do so, we have to combine the LEN function with another basic function namely the SUBSTITUTE function. For example, we want to count the “o” letter in the entire dataset. So,

  • Select a cell and apply the customized formula.
=LEN(B5)-LEN(SUBSTITUTE(B5,”o”,””)

add len function gor specific character

Formula Breakdown

  • LEN(B5) represents the total character in cell B5.
  • SUBSTITUTE(B5,”o”,””) replace the “o” character with “”. So, it represents the character excluding “o”.
  • LEN(B5)-LEN(SUBSTITUTE(B5,”o”,””) calculate total character minus characters excluding the “o” letter. In another sense, it presents the number of the “o” letter in the cell.
  • You can use the fill handle to insert the formula into the entire column.

use fill to insert the function in google sheets

Note: You can also count repetitive words in the same process.

Things to Remember

  • Be careful while applying multiple functions.
  • Always use the fill handle to insert the function downward.

Conclusion

We hope that this article will help you to get a clear understanding of the Google Sheets LEN function. To explore more about Google Sheets, visit the OfficeWheel website.

Annyca Tabassum

Annyca Tabassum

Hello, I'm Annyca Tabassum. I currently work for the SOFTEKO as a technical writer and content developer. I have completed my graduation and post-graduation from SUST.

We will be happy to hear your thoughts

Leave a reply

OfficeWheel
Logo