REPLACEB Function

Replaces characters at a byte position with new text.

Category

Text

Available in

All versions, Microsoft 365

Returns

Text

Want to practice REPLACEB in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

REPLACEB is the “byte” version of REPLACE. It counts bytes instead of characters — but only when a double-byte language (Japanese, Chinese or Korean) is set as Excel's default editing language. Then each double-byte character counts as 2.

In every other setup, including English, REPLACEB gives exactly the same result as REPLACE. Unless you build workbooks for double-byte systems, use REPLACE.

Syntax

=REPLACEB(old_text, start_num, num_bytes, new_text) Explain

Arguments

ArgumentRequired?What it does
old_textYesThe original text.
start_numYesThe byte position to start replacing.
num_bytesYesHow many bytes to remove.
new_textYesThe text to put in.

Examples

Example 1 — Masking digits

Hide four digits in the middle of each account.

B2fx=REPLACEB(A2, 6, 4, "****")
AB
1AccountMasked
2ACCT-55120934ACCT-****0934
3ACCT-88013377ACCT-****3377
=REPLACEB(A2, 6, 4, "****") Explain

With English as the default language, =REPLACE(A2, 6, 4, "****") returns the same answers.

Common mistakes

  • Results change with language settings. A workbook using REPLACEB can give different answers on a computer whose default language is Japanese, Chinese or Korean. Prefer REPLACE for workbooks you share.

Notes

Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.