LENB Function
Returns the byte length of text.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| text | The text or cell reference whose byte count is returned. | Required |
Basic Example
Byte length of ASCII text
=LENB("Hello")Each ASCII character is one byte, so the byte count equals the character count of 5.
Advanced Examples
Example 1: DBCS text in Excel
Cell A1 contains the two Chinese characters "你好" and Excel runs in a DBCS localeEach character counts as two bytes
=LENB(A1)Example 2: Detect double-byte content
Compare LEN and LENB on mixed textWhen LENB > LEN, the string has multi-byte characters
=LENB(A1)-LEN(A1)How LENB Works
LENB counts the storage bytes of the string. In Excel's DBCS language editions, East Asian characters occupy two bytes while ASCII occupies one; in single-byte editions every character is one byte, making LENB identical to LEN.
Important Notes & Limitations
In Excel on single-byte systems LENB always equals LEN, so it is only useful in DBCS locales.
Google Sheets counts bytes using UTF-8, where many non-ASCII characters are 2-3 bytes, differing from Excel's DBCS behavior.
Does not count formatting or formula length, only the resulting text value.
Common Errors & Fixes
LENB equals LEN unexpectedlyRunning Excel in a single-byte locale where every character is one byte.Fix: Use the difference LENB-LEN only on DBCS-enabled Excel, or rely on Google Sheets' UTF-8 counts for web data.
Download Practice File
LENB
lenbPractice LENB with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the LENB function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps