Text

Counting characters in a code

Definition

Counting characters in a code means giving LEN the cell that holds the code, including any hyphen.

Syntax

=LEN(text)

Arguments

Argument Meaning
text The cell that holds the code to measure.

Worked example

A stock list stores short lot codes in B2:B4.

A: Bin B: Code
1 Q-12
2 M-8
3 R-40

Formula: =LEN(B2)

Result: 4. Q-12 has four characters, and the hyphen counts as one of them.

Practice

Cell A2 holds AB-19. In B2, write a formula that returns the length of A2.

  1. In B2, write a LEN formula for A2.
Step 1 of 2
Formulas here use English function names, such as SUM, and a period as the decimal separator, in every language.
Loading the sheet…

Related functions

LEN is the function that counts every character in that code.

Common mistake

Subtracting the hyphen by hand, as in =LEN(B2)-1: that returns 3, but the hyphen is a real character, so the length is 4.

Related functions

These links are related functions.