Excel - LEN Function



LEN Function

The EXCEL LEN function returns a numeric value representing the input strings length. Unlike the LENB function, it counts 1 byte for each letter. This function is supported for the single-byte character set. This eminent function is combined with other functions like LEFT, FILTER, SUM, AVERAGE, and many more to evaluate complicated expressions. If used with the conditional operator, the LEN function will return the TRUE/FALSE value.

Compatibility

This advanced Excel function is compatible with the following versions of MS-Excel −

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016

Syntax

The syntax of the LEN function is as follows −

LEN (text) 

Arguments

You can use the following arguments with the LEN function −

Argument Description Required/ Optional
Text It indicates the input string where empty spaces will also be countable in form of characters. Required

Points to Remember

  • The LEN function will return zero if the cell reference points to the empty cell value in the first argument.
  • If the first argument refers to the error, the LEN function will return the same error value.
  • The LEN function is incompatible with the DBCS set-supported foreign languages.

How to use LEN Function in Excel?

  • Expediate the new Excel worksheet, place the cursor, and double-click on the targeted cell.
  • Type the =sign and then write the LEN(cell reference/ text) .
  • Finally, hit the Enter button.

Examples of LEN Function

A few amazing examples of LEN function are given below −

Example 1: How to Compute the Length of Input Text in Excel?

This function returns the number of characters in a text string, including spaces, punctuation, and special characters.

Solution

Step 1 − Assume the sample dataset consists of Text and No. of characters columns. Write the formula =LEN(B3) and press the Enter tab.

Text and No of characters Columns

Therefore, the LEN function will retrieve the value of 5.

Retrieve The Value of 5

Step 2 − Drag the + sign(fill handle) and drop it to the C9 cell to compute the length of the range C4:C9 cell.

Length of Range C4:C9 Cell

Example 2

The LEN function will return zero if the cell reference refers to the empty cell value in the first argument.

Solution

In this example, the B3 cell contains an empty text value when you evaluate the formula =LEN(B3) in the C3 cell.

B3 Cell Contains Empty Text Value

After pressing the Enter tab, the LEN function will retrieve 0.

LEN Function Will Retrieve 0

Example 3: Merging LEN, FILTER, and AVERAGE Functions

The LEN, FILTER, and AVERAGE functions in Excel to perform calculations based on specific text conditions.

Solution

You intend to calculate the average of the input string's length greater than 8. It can be accomplished by making complex expressions using LEN, FILTER, and AVERAGE functions.

Lets commence with writing the expression =AVERAGE(LEN(FILTER(B3:B9,LEN(B3:B9)>8))) in the C3 cell and press the Enter tab.

Merging LEN, FILTER, and AVERAGE Functions

Explanation

=AVERAGE(LEN(FILTER(B3:B9,LEN(B3:B9)>8)))
  • The inner LEN(B3:B9)>8 expression verifies the cell range length and gives you the TRUE/FALSE value.
  • FILTER(B3:B9, LEN(B3:B9)>8) filtered the range B3:B9 and returned only those text strings whose value is larger than 8.
  • The outer LEN function LEN(FILTER(B3:B9, LEN(B3:B9)>8)) will calculate the length of the filtered text values.
  • Therefore, the AVERAGE function will calculate the average of the computed length of the filtered string.

Therefore, the resulting value is 11.6.

Resulting Value is 11.6

Download Practice Sheet

You can download and use the sample data sheet to practice the LEN function.

Advertisements