LEN() – Returns the length of a text string

The LEN() function returns the number of characters in a given text string.

Syntax

LEN(text)

  • text: The text string or a cell reference containing the text whose length you want to find.

Basic example

LEN(T1A1)

Returns the number of characters in the text contained in cell T1A1.

  • If T1A1 = "Example": LEN(T1A1)7
  • If T1A1 = "MathGrid Plugin" (spaces are counted): LEN(T1A1)15
  • If T1A1 is empty (contains an empty string ""): LEN(T1A1)0
  • If T1A1 contains the number 12345 (numbers are treated as text for length calculation): LEN(T1A1)5
  • If T1A1 = " Text " (leading/trailing spaces are counted): LEN(T1A1)8

Key features

  • Character count: Counts all characters, including letters, numbers, spaces, and symbols.
  • Numeric input: If a number is provided (or a cell reference to a number), LEN() counts the digits as characters (e.g., LEN(100) is 3).
  • Empty string: The length of an empty string ("") is 0.

Practical uses

  • Validating data entry to ensure text meets minimum or maximum length requirements.
  • As part of other formulas, for example, to extract the last N characters if N varies: RIGHT(text, LEN(text) - position_of_interest).
  • Checking if a cell is empty (though IFBLANK() might be more direct).
  • Truncating text dynamically based on available space.

Common mistakes

  • Ignoring spaces: LEN() counts all spaces, including leading, trailing, and multiple spaces between words. If you need to count characters without certain spaces, use TRIM() first (e.g., LEN(TRIM(T1A1))).
  • Expecting it to count words: LEN() counts characters, not words.
  • Using it with non-textual data directly: While it converts numbers to text, applying it to complex data types or errors directly might lead to unexpected results or errors; ensure the input is a text string or a cell that can be represented as text.

Report issue

Features, Pricing, Documentation, Support, Login

MathGrid ©

Features,
Pricing,
Documentation,
Support,
Login

MathGrid ©

Back to top Arrow