Excel LEN Function Explained

Last Updated on 07/12/2024
Reading time: 2 minutes

The LEN function in Excel counts characters in a cell, including spaces, numbers, and symbols. It’s useful for logical tests, data validation, or formatting.

What Does the LEN Function Do?

The function helps you count all characters in a cell. It includes:

  • Letters
  • Numbers
  • Spaces
  • Symbols

The LEN function only needs one argument:

  • A cell reference, like =LEN(A1).

Examples of LEN Function

FormulaResultDescription
=LEN("Excel 365")9Counts letters, spaces, and numbers.
=LEN("Hello!")6Includes punctuation like !.
=LEN(A1)VariesDepends on the content in cell A1.

Why Use LEN for Logical Tests?

The function is helpful when checking data, such as validating phone numbers. For example:

  • A U.S. phone number should have 14 characters, including spaces and symbols.
  • You can use =LEN(A1) to check if the length matches 14.
Which phone number are wrong

The LEN function will help to ckeck if the phone number pattern respect the US phone number: (3) 3-4 digits

  • 3+3+4 = 10
  • But we must also include the parenthesis, the space (after the second parenthesis), and the hyphen.
  • So, 1+3+1+1+3+1+4 = 14 digits
The LEN function should return 14

IMPORTANT REMARK: The LEN function can handle all the characters in a cell, from letters to spaces to symbols.

As you can see, most results return 14, but not all. Visualizing which result is different from 14 is not easy. This is why we must convert the formula into a test case.

Convert the formula into a logical test.

Creating a logical test is not difficult. You have to add the expected result directly to the formula.

Convert the result of the LEN function into a test case

Now, finding the wrong phone number is easy because the test result is FALSE. But we can do better.

  • We can filter on column D to keep only the FALSE
  • Use the IF function to Customize the result, like =IF(LEN[@Phone Number])<>14,"Wrong phone number","")
  • Or highlight with a color the cases where the result is different of 14 with the conditional formatting

Start using the LEN function today to make your Excel tasks easier!

Leave a Reply

Your email address will not be published. Required fields are marked *

Excel LEN Function Explained

Reading time: 2 minutes
Last Updated on 07/12/2024

The LEN function in Excel counts characters in a cell, including spaces, numbers, and symbols. It’s useful for logical tests, data validation, or formatting.

What Does the LEN Function Do?

The function helps you count all characters in a cell. It includes:

  • Letters
  • Numbers
  • Spaces
  • Symbols

The LEN function only needs one argument:

  • A cell reference, like =LEN(A1).

Examples of LEN Function

FormulaResultDescription
=LEN("Excel 365")9Counts letters, spaces, and numbers.
=LEN("Hello!")6Includes punctuation like !.
=LEN(A1)VariesDepends on the content in cell A1.

Why Use LEN for Logical Tests?

The function is helpful when checking data, such as validating phone numbers. For example:

  • A U.S. phone number should have 14 characters, including spaces and symbols.
  • You can use =LEN(A1) to check if the length matches 14.
Which phone number are wrong

The LEN function will help to ckeck if the phone number pattern respect the US phone number: (3) 3-4 digits

  • 3+3+4 = 10
  • But we must also include the parenthesis, the space (after the second parenthesis), and the hyphen.
  • So, 1+3+1+1+3+1+4 = 14 digits
The LEN function should return 14

IMPORTANT REMARK: The LEN function can handle all the characters in a cell, from letters to spaces to symbols.

As you can see, most results return 14, but not all. Visualizing which result is different from 14 is not easy. This is why we must convert the formula into a test case.

Convert the formula into a logical test.

Creating a logical test is not difficult. You have to add the expected result directly to the formula.

Convert the result of the LEN function into a test case

Now, finding the wrong phone number is easy because the test result is FALSE. But we can do better.

  • We can filter on column D to keep only the FALSE
  • Use the IF function to Customize the result, like =IF(LEN[@Phone Number])<>14,"Wrong phone number","")
  • Or highlight with a color the cases where the result is different of 14 with the conditional formatting

Start using the LEN function today to make your Excel tasks easier!

Leave a Reply

Your email address will not be published. Required fields are marked *