LEFTB Function

LEFTB Function

LEFTB Function

Extracts a specified number of bytes from the start of a text string. LEFTB is mainly a legacy compatibility function for older DBCS workflows.

ExcelClash Team
PUBLISHED

Summary

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.

Purpose

Extract bytes from the start of text

Returns text from the left side, but counts bytes instead of characters.

Return Value

A text string

Returns the left portion of the text based on the byte count you specify.

Syntax

=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.

Arguments

  • text - [Required] The text string or cell reference you want to extract from.
  • num_bytes - [Optional] The number of bytes to return from the left side. The default is 1.

LEFTB vs LEFT

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.

Using LEFTB

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.

  • Use LEFTB when an old workflow measures text width in bytes.
  • Use LEFT when you simply need the first characters of a string.
  • Be careful when mixing single-byte and double-byte characters, because the result may not match a character count.

Example 1 - Extracting Bytes from Plain Text

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"
Check Answer
Challenge #1
Target: Sheet1!F1
Simple Byte Extract

Extract the first 3 bytes from "ABC". Formula: =LEFTB("ABC",3).

Example 2 - Extracting Full-Width Characters

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"
Check Answer
Challenge #2
Target: Sheet1!F2
Full-Width Byte Extract

Extract the first 2 bytes from "AB". Expected result: "A". Formula: =LEFTB("AB",2).

Example 3 - Returning a Prefix from Japanese Text

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
Check Answer
Challenge #3
Target: Sheet1!F3
Japanese Prefix by Bytes

Extract the first 4 bytes from B2. Formula: =LEFTB(B2,4).

Example 4 - Using a Byte Count from a Cell

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"
Check Answer
Challenge #4
Target: Sheet1!F4
Use a Byte Count from a Cell

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.

Conclusion Recap

  • Summary: LEFTB returns text from the left side based on bytes, not characters.
  • Syntax: =LEFTB(text, [num_bytes]).
  • Key point: LEFTB is mainly a legacy compatibility function.
  • Practical usage: Older exports, older systems, and byte-limited text fields.
  • Best rule: Use LEFT for modern character-based work, and LEFTB only when byte counting is the real requirement.
Tactical Arena
Select Scenario:
Share LEFTB Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.