
Extracts a specified number of bytes from the start of a text string. LEFTB is mainly a legacy compatibility function for older DBCS workflows.
The Excel LEFTB function returns a specified number of bytes from the start of a text string. That is different from LEFT, which counts characters. In older Double-Byte Character Set (DBCS) environments, some characters use 2 bytes, so a byte-based result can differ from a character-based result.
Microsoft now treats LEFTB as a legacy compatibility function. In newer Excel versions, LEFT is the preferred function, and Microsoft notes that LEFT now supports Unicode through newer compatibility behavior. So LEFTB is mainly worth learning when you are working with older files, older systems, or lessons about byte-based text handling.
Returns text from the left side, but counts bytes instead of characters.
Returns the left portion of the text based on the byte count you specify.
=LEFTB(text, [num_bytes])
The first argument is the text to extract from. The second argument is the number of bytes to return. If you omit num_bytes, Excel uses 1. In byte-based languages, that can matter because one visible character may take more than one byte.
The difference is simple: LEFT counts characters, while LEFTB counts bytes. For plain single-byte text like "ABC", the two functions usually give the same result. For full-width or DBCS text, they may return different results.
| Sample Text | Count | LEFT Result | LEFTB Result |
|---|---|---|---|
| "ABC" | 2 | "AB" | "AB" |
| "AB" | 2 | "AB" | "A" |
| "こんにちは" | 4 | "こんにち" | "こん" |
When LEFTB is used on multi-byte text, Excel returns whole characters only. If the requested byte count would cut through the middle of a character, Excel does not return half of that character.
LEFTB appears mainly in legacy spreadsheets that were designed around byte limits instead of character limits. For example, an older export file may allow only a fixed number of bytes in a field. In that case, LEFTB can trim the text to the allowed byte width before export.
In modern workbooks, LEFT is usually the better first choice. Use LEFTB only when the requirement is specifically about bytes, not just visible characters.
With plain ASCII text, each character is effectively counted one byte at a time, so LEFTB behaves much like LEFT. Asking for 3 bytes from "ABC" returns the whole string.
=LEFTB("ABC", 3) // Returns "ABC"
Extract the first 3 bytes from "ABC". Formula: =LEFTB("ABC",3).
This example shows why LEFTB exists. In full-width text, one visible character can take 2 bytes. So a byte count of 2 returns only the first full-width character, not two characters.
=LEFTB("AB", 2) // Returns "A"
Extract the first 2 bytes from "AB". Expected result: "A". Formula: =LEFTB("AB",2).
In Japanese text, LEFTB follows the byte count rather than the character count. If each character uses 2 bytes in the DBCS context, asking for 4 bytes returns the first two characters.
=LEFTB(B2, 4) // Returns the first 2 Japanese characters
Extract the first 4 bytes from B2. Formula: =LEFTB(B2,4).
The byte count does not need to be typed directly into the formula. You can store it in a cell and let the formula read it. That makes the extraction rule easier to adjust later.
=LEFTB("ABCDEFGHI", A1) // If A1 is 5, returns "ABCDE"
Use the number in A1 as the byte count when extracting from "ABCDEFGHI". Formula: =LEFTB("ABCDEFGHI",A1).
The main thing to remember is that LEFTB is not the normal choice in modern Excel work. It exists for compatibility with byte-based text handling. If your task is about visible characters, use LEFT. If your task is about byte limits in older DBCS-style workflows, LEFTB may still be relevant.
LEFTB returns text from the left side based on bytes, not characters.=LEFTB(text, [num_bytes]).Tell your friends about this post