LEN Function in Google Sheets
If you’ve spent any time inside a spreadsheet, you will probably have worked with text (as well as numbers obviously).
Thankfully, Google Sheets makes it easy to do some time saving text manipulation.
The LEN function in Google Sheets is a pretty common text function. It’s also pretty useful. LEN in Google Sheets counts the number of characters in a string. It’s pretty useful for counting page title and meta description length.
What is the LEN Function?
The purpose of the LEN function is to return the length of a string. In other words, it counts the number of characters.
The syntax of the function is:
It takes in just one argument, text, and it’s the string for which you want to count the number of characters.
The formula simply returns the length of the text variable. Important to note, that it counts every character, including letters, numbers, special characters, punctuation marks and spaces.
When to use LEN for marketing stuff?
- Writing title tags and meta descriptions.
- Writing PPC ad copy.
- Finding overly-long URLs in audits and migrations.
How To Use The LEN Function in Google Sheets
Using LEN is pretty straightforward.
There are two possible ways to provide the function with the source string:
- Direct text value
- Cell reference
Direct text value
- The formula accepts direct values within a pair of double-quotes and counts the characters in this text.
- The function of this example is
=LEN(“sheets for marketers is pretty cool.”).
- It returns 35 because the text within the double-quotes has 35 characters including the spaces.
- It also accepts a reference to a cell that has text in it. The function will then return the number of characters in this given cell. In real-life formulas, you are more likely to use this method over the direct text values.
- For instance, cell B2 has the following function here:
- The output is 35 because the text in the referenced cell (A2) has 35 characters.
- Every time you change the text in cell A2, the result of the function changes dynamically as well.
LEN Formula Example
Let’s see an example where the LEN function can be useful.
Say you want to check page titles for an article and you want to have the right length.
With the LEN function, you can quickly calculate the number of characters in each title. You just need to write a LEN function for each title and supply the cell reference of the corresponding title as the text argument.
Sprinkle in some conditional formatting and you’ve got a really simple way of seeing if your page titles are too long (or too short):
Using the LEN function in Google Sheets really is that simple.
Google doesn’t have a recommended page title length, however the current best practice is 50-60 characters (with spaces).
LEN + SUBSTITUTE
You can use LEN for anything that has a minimum or maximum character counts like titles, meta descriptions, tweets or social media bios.
For these cases, you always need to count the space characters as well.
Other times you might want to ignore the spaces and only count the printed characters. To do this, you need to modify the function a bit.
You can do it by nesting the SUBSTITUTE function inside the LEN formula. The SUBSTITUTE function is used to replace a specific text with a new text in a string, but it can also be used to remove a text (or a character).
Here you can use it to replace the space characters (“ “) with no characters (““).
The formula to get the character count without spaces is:
=LEN(SUBSTITUTE(A2, “ “, ““)
The first argument (A2) is the reference to the source text as it would be in a simple LEN formula.
If you were to use the SUBSTITUTE formula on its own, it would return “sheetsformarketersisprettycool.”. The wrapping LEN formula counts the number of characters of this modified text.
This way it returns 30 instead of 35 because its text argument (the output of the SUBSTITUTE function) doesn’t have the spaces anymore.
If you have a passion for counting page titles and meta description lengths, you need to take a long hard look at yourself in the mirror.
In the meantime, you might also like these resources:
- SEO Page Title Best Practices (+ Examples)
- How to Write a Meta Description for SEO (+ Examples)
- Check out on-page SEO and audit Google Sheets Templates in the directory