LEFTB in Google Sheets: Extract a Byte-Counted Prefix
Extract documented byte-counted prefixes with optional-count examples and safe boundary checks.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Choose the right unit first
An import layout may specify a byte-counted prefix rather than a number of displayed characters. LEFTB is relevant to that layout. If the requirement is simply “the first three characters,” begin with LEFT instead.
Syntax and arguments
=LEFTB(string, [num_of_bytes])
string supplies the text. The optional count defaults to 1 and must be nonnegative. A count beyond the string’s byte length returns the whole string. Google’s displayed signature lacks optional brackets, but its argument description and notes explicitly make the count optional. For single-byte input, the documented result agrees with LEFT. See Google’s LEFTB reference.
Extract a shipment prefix
Put BOX-731 in A2 and 熊本-04 in A3. The formulas below use those cell references.
| Formula | Expected result | Purpose |
|---|---|---|
=LEFTB(A2,3) |
BOX | Three-byte ASCII prefix |
=LEFTB(A2) |
B | Omitted count |
=LEFTB(A2,0) |
empty string | Zero-length prefix |
=LEFTB(A2,40) |
BOX-731 | Count beyond input length |
=LEFTB(A3,4) |
熊本 | Two complete double-byte characters |
=LEFTB(A3,5) |
熊本- | The same prefix plus ASCII hyphen |
These results are independent deductions from the published rules. They have not been run in Google Sheets. In A3 the selected prefix uses 2 + 2 + 1 units for 熊, 本 and -. The chosen cuts end at complete-character boundaries; they are not tests of partial-character behavior.
Review an import specification
Before copying a formula down an entire export, write down the field boundary and representative input types. For the illustrated layout, a four-unit prefix ends after the place label. A five-unit prefix includes its separator. Preserve the source column and inspect records with different prefix lengths rather than assuming every row has the same structure.
Do not use a local file’s encoded size as the count without establishing that the export format and spreadsheet count use the same definition. In particular, this guide does not equate Google’s byte units with UTF-8 bytes.
Troubleshooting and limits
- For the ASCII identifier above, one returned letter is expected when the count was omitted.
- A large count does not pad a short identifier; the original text is returned.
- Check negative counts before use. The source establishes a nonnegative requirement, but this guide does not assign an unverified error code.
- Avoid cuts inside double-byte characters. Emoji, combining marks, fractional counts and split-character results are outside the verified examples.
Versions, related functions and verification
The cached Google help snapshot was retrieved on 19 October 2026 and reported a crawl age of “last year”; it supplies no minimum Sheets version. Other spreadsheet applications are not used as evidence for these examples. Native tests and screenshots remain pending.
LEFT explains character-counted prefixes. Google’s LEFTB page also links its MIDB, RIGHTB and LENB documentation for interior sections, suffixes and length; those functions’ detailed contracts are separate and are not inferred from LEFTB.