Text function

LEFTB function

Returns the first characters of a text up to a given number of bytes; double-byte characters count as 2 when a DBCS language is the default.

Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

LEFTB(text, [num_bytes])
ArgumentWhat it means
textRequiredThe text or cell.
num_bytesOptionalHow many bytes to return. Default 1.

Returns: Text: the leading characters that fit into num_bytes.

How LEFTB works

LEFTB is the byte-based version of LEFT. Instead of counting characters, it counts bytes, which matters for text in Japanese, Chinese or Korean, where each kanji, hanzi or hangul character occupies 2 bytes in the legacy double-byte encodings, while Latin letters and digits use 1. Fixed-width export files for banks or government systems in those countries often specify field widths in bytes, and LEFTB lets you cut text to fit.

Byte counting only happens when a double-byte (DBCS) language - Japanese, Chinese (Simplified or Traditional) or Korean - is set as the default editing language under File > Options > Language. With any other default language every character counts as 1 byte and the B version behaves exactly like the normal one.

If the byte limit would cut a double-byte character in half, Excel does not return half a character; the result can be one byte shorter than requested (sometimes padded with a space). Test your formulas on real data when that matters.

Examples

1First 4 bytes of a Japanese address (Japanese default language)

B2fx=LEFTB(A2,4)
AB
1Address
2東京都港区東京

Result: 東京

Each kanji is 2 bytes, so 4 bytes hold exactly two characters.

2Mixed Latin and kanji text (Japanese default language)

B2fx=LEFTB(A2,5)
AB
1Code
2ABC東京ABC東

Result: ABC東

ABC uses 3 bytes and 東 the next 2, so 5 bytes return four characters. LEFT(A2,5) would return the whole text.

3Same address with an English default language

B2fx=LEFTB(A2,4)
AB
1Address
2東京都港区東京都港

Result: 東京都港

Without a DBCS default language each character counts as 1 byte, so LEFTB behaves exactly like LEFT and returns 4 characters.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!num_bytes is negative.Use 0 or a positive number.

Tips

  • Check the byte length of the whole value first with LENB to see whether it needs cutting at all.
  • For normal character-based work use LEFT; it gives the same result on every computer.

Google Sheets

LEFTB also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

LEFTB in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
FrenchGAUCHEB
GermanLINKSB
PolishLEWYB
RussianЛЕВБ
SpanishIZQUIERDAB