Practice / Text

Count product code characters (LEN)

Easy Text

Shipping labels only fit a fixed number of characters, and every product code in A2:A5 is a different length — PRD-1023 is not the same width as SKU-9. Fill Code length in C2:C5 with how many characters each code contains. The dash counts.

Your solution should use cell references so it updates automatically when Test Case input values change.

Hints 0/4
Solutions 2
–
Test case
1
2
3
Reset
Submit
fx
A
B
C
D
E
F
G
1
2
3
4
5
6
7
8
9
10
Loading interactive spreadsheet...
Preparing grid cells and formula calculation engine
○ Ready Enter formula in highlighted cells, then click Submit.

Notes

LEN(text) returns the number of characters, including dashes, digits, and spaces. LEN("PRD-1023") is 8: three letters, one dash, and four digits. A hardcoded 8 fails as soon as the code in A2 changes.

Function guide

FAQ

How do I count characters in a cell?

Use =LEN(A2). It returns the number of characters stored in A2. LEN("PRD-1023") is 8.

Does LEN count the dash and spaces?

Yes. Every character counts: letters, digits, dashes, and spaces. "SKU-9" is 5. "Ana Lee" is 7 because of the space.

What if the code has extra spaces?

A trailing space adds 1 to the count. =LEN(TRIM(A2)) removes leading and trailing spaces before measuring. Characters in the middle, including the dash, stay.