The Excel REPLACEB function overwrites part of a text string, with the target region defined by a starting byte and a length in bytes. It is the byte-counting twin of REPLACE, built for double-byte character set (DBCS) languages — Japanese, Chinese, and Korean — where each native character occupies 2 bytes when such a language is the system default. Working in English or any other single-byte language? REPLACEB behaves exactly like REPLACE — just use REPLACE.
Syntax
| Argument | Description | |
|---|---|---|
old_text | Required | The original string. |
start_num | Required | The byte position where replacement begins. The first byte is 1. |
num_bytes | Required | How many bytes to remove before inserting new_text. |
new_text | Required | The text to insert. Its own length is irrelevant — it can be shorter, longer, or empty. |
Available in: all Excel versions. Byte counting activates only when a DBCS language (Japanese, Chinese Simplified/Traditional, or Korean) is the system default language; otherwise positions and lengths are in characters and REPLACEB matches REPLACE exactly. Positions usually come from FINDB or SEARCHB.
REPLACEB vs REPLACE: byte-defined surgery
On a Japanese-locale system, 東京2026 spans 8 bytes — the kanji occupy bytes 1–4 and the year occupies bytes 5–8. Byte coordinates drive the edits:
| A | B | C | |
|---|---|---|---|
| 1 | Text in A2: 東京2026 | Formula | Result (Japanese locale) |
| 2 | byte positions: 東=1–2, 京=3–4, 2026=5–8 | =REPLACEB(A2, 5, 4, "2027") | 東京2027 |
| 3 | =REPLACEB(A2, 1, 4, "大阪") | 大阪2026 | |
| 4 | =REPLACEB("Dallas", 1, 3, "Au") | Aulas — same as REPLACE |
Updating a byte-defined field inside a fixed-width record is the bread-and-butter case — the file spec says “bytes 11–14”, and REPLACEB speaks that language:
Pair with FINDB when the position must be discovered rather than known:
Try it: byte-replacement sandbox
Pick the byte region to overwrite and the replacement text, and toggle the system locale to see how byte counting changes the cut.
Errors & common pitfalls
Pitfall: results depend on the system language. =REPLACEB(A2, 5, 4, ...) targets different text on a Japanese-locale machine than on a US-locale one — the byte grid moves underneath the formula. In shared workbooks, byte-based edits are a portability trap; note the assumption or use REPLACE.
Working in English? Use REPLACE. On single-byte locales REPLACEB adds nothing over REPLACE. And if you want to replace specific text rather than a position, you want SUBSTITUTE in the first place.
Pitfall: slicing a character in half. If start_num or the byte count cuts into the middle of a 2-byte character, the surviving half becomes a space in the result. Keep DBCS edits on even boundaries — or anchor them with FINDB so they start on a real character.
#VALUE! — bad coordinates. start_num must be at least 1 and num_bytes zero or more. Arithmetic like FINDB(...) - 2 drifting below 1 is the usual cause; clamp with MAX where positions are computed.
Practice workbook
Frequently asked questions
What's the difference between REPLACEB and REPLACE?
What's the difference between REPLACEB and SUBSTITUTE?
Why does REPLACEB give me the same answer as REPLACE?
Does new_text have to fit the byte count I removed?
num_bytes only sizes the hole; new_text can be longer, shorter, or empty. =REPLACEB(A2, 5, 4, "") deletes bytes 5–8 outright, and inserting without removing is num_bytes = 0.Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class