Text

LENB Function in Excel

Returns the number of bytes used to represent the characters in a text string.

Syntax

  • =LENB(text)

Arguments

  • text (required): Text string

Examples

  • =LENB(A1) - Byte length of text - Result: Number of bytes

Excel LENB function documentation

  • LENB returns the length of text in bytes, not characters.
  • Syntax: =LENB(text). It is relevant for double-byte character set scenarios.
  • Use LENB when legacy storage limits are defined in bytes rather than character counts.
  • Text function category: [/categories/text/](/categories/text/).

LENB syntax and byte-count behavior

  • text is required and can be a cell or literal string.
  • Single-byte characters may count as 1 byte; double-byte characters may count as 2.
  • LENB results can differ from LEN for multilingual strings.
  • Always validate byte thresholds before system imports with strict limits.

Step-by-step: enforce byte-based field limit

  • Step 1 - Source text in A2 with potential multilingual input.
  • Step 2 - In B2 use =LENB(A2).
  • Step 3 - Add flag: =IF(B2>40,"Too long","OK").
  • Step 4 - Filter flagged rows before export to downstream systems.

LENB vs LEN vs data validation

  • LENB checks byte length and is useful for legacy integrations.
  • LEN checks character count and is better for user-facing limits.
  • Data Validation can enforce simple limits after your byte analysis.
  • Readability formatting can still be done with [TEXT](/functions/text/) outputs.

Worked examples to copy

  • Byte length: =LENB(A2).
  • Compare with LEN: =LENB(A2)-LEN(A2).
  • Limit check: =IF(LENB(A2)<=20,"Pass","Fail").
  • Null-safe style: =IF(A2="",0,LENB(A2)).

People also ask

  • Why is LENB bigger than LEN? - Double-byte characters increase byte count.
  • Should I always use LENB? - Only when limits are byte-based, not character-based.
  • LENB for English text? - It often matches LEN for pure single-byte strings.
  • Can LENB help prevent import errors? - Yes, for systems enforcing byte caps.

Common errors

  • Different from LEN for double-byte characters

Use cases

  • Asian text processing
  • Byte counting
  • Data validation

Frequently asked questions

  • What is the LENB function in Excel? LENB returns the number of bytes used to represent the characters in a text string. The syntax is =LENB(text). Typical use cases include asian text processing, byte counting, data validation.
  • How do I use the LENB function? To use LENB, type =LENB( in a cell and provide the required arguments. Excel will show you the syntax and parameter hints as you type. Make sure to close the parentheses and press Enter to execute the function.
  • Can LENB handle different text formats? Yes, LENB can work with various text formats including strings, cell references containing text, and text values returned by other functions. It processes text according to its specific functionality.
  • Why is LENB not working in my Excel? Common issues with LENB include Different from LEN for double-byte characters. Start by checking the syntax =LENB(text), then verify each referenced cell or range.

Editorial review

  • Reviewed by Excel.Directory Editorial Team. Updated May 2026.

When to use LENB

  • Asian text processing — common Text scenario for LENB.
  • Byte counting — common Text scenario for LENB.
  • Data validation — common Text scenario for LENB.

LENB in the Text category

  • Browse all Text functions at /categories/text/ for related formulas.
  • LENB syntax: =LENB(text)
  • text (required): Text string
  • Confirm LENB arguments match the syntax shown above before filling down.
  • Lock table and range references with $ when copying formulas across rows or sheets.

Formula checklist before you copy down

  • Confirm LENB arguments match the syntax shown above before filling down.
  • Lock table and range references with $ when copying formulas across rows or sheets.
  • If results look wrong, check for text stored as numbers and invisible spaces with TRIM.
  • Spot-check three known input rows manually against expected output.

Related Excel functions

  • LEN (/functions/len/): Returns the number of characters in a text string.
  • LEFTB (/functions/leftb/): Returns the leftmost characters from a text value based on bytes.
  • RIGHTB (/functions/rightb/): Returns the rightmost characters from a text value based on bytes.

Errors to watch for

  • Different from LEN for double-byte characters — review causes on linked error pages in the directory.

Copy-paste audit workflow

  • Enter LENB on three test rows with known expected output documented on a QA tab.
  • Fill down only after absolute references are locked on lookup tables and rate tables.
  • Compare against manual calculation or a calculator for financial and statistical functions.
  • Search this directory for comparison guides when choosing between similar functions in the same category.

LENB worked examples to copy

  • =LENB(A1) — Byte length of text. Expected result: Number of bytes.

LENB reference summary for crawlers and offline review

  • LENB belongs to the Text category in Excel. Returns the number of bytes used to represent the characters in a text string.
  • Full syntax: =LENB(text). Open /functions/lenb/ for parameters, FAQs, and related pages.
  • Common mistakes: Different from LEN for double-byte characters
  • Pair this function with comparison guides when another Excel formula might fit the same task better.
  • Review fix-excel-formula-errors when unexpected errors appear after upgrading Excel or sharing across locales.