Skip to main content

Excel REPLACEB Function

The REPLACEB function replaces part of a text string with a new text string based on the number of bytes you specify. REPLACEB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.

replaceb function 1


Syntax

=REPLACEB(old_text, start_num, num_bytes, new_text)


Arguments

  • old_text (required): The text string in which you want to replace some characters.
  • start_num (required): The position of the first byte of character you want to replace in old_text.
  • num_bytes (required): Specifies the number of bytes of characters to replace in old_text starting from start_num.
  • new_text (required): The new text to replace characters in old_text.

Return Value

The REPLACEB function returns specified number of characters.


Function Notes

  • Spaces count as characters.
  • REPLACEB always counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, REPLACEB counts each character as 1 just like REPLACE.
  • If start_num is greater than the length of old_text, REPLACEB returns an empty text ("").
  • If start_num is less than the length of old_text but start_num + num_bytes exceeds the length of old_text, REPLACEB replaces the characters from the No. start_num to the end of old_text with new_text.
  • REPLACEB returns the #VALUE! error if:
    • start_num < 1;
    • num_bytes is negative.
  • REPLACEB counts actual values instead of the look of your data. For example, A1 is date 9/1/2022, >REPLACEB(A1,1,1,8) returns 84805, as the actual value in A1 is 44805 which was just formatted as a date value. To use REPLACEB with dates, you should take advantage of the TEXT function.

Example

To have REPLACEB replace the specified bytes of characters from the old text strings at the positions specified in the table below with the new text, please copy or enter the formula below in the top cell (G6) of the result list, and press Enter to get the result. Then select the result cell, and drag the fill handle (the small square in the lower-right corner of the selected cell) down to apply the formula to the below cells.

=REPLACEB(B6,C6,D6,E6)

replaceb function 2

Instead of cell references, you can type the actual old_text, start_num, num_bytes and new_text values in the formula as shown below.

=REPLACEB("你在干什么",7,4,"嘛")

Note: You should enclose the text string in an Excel formula with double quotes (""). Note that cell references, numbers or dates should not be within quotes.


REPLACEB VS. REPLACE

REPLACEB counts each double-byte character as 2 and each single-byte character as 1. While REPLACE counts both double- and single-byte character as 1. You can compare the results returned by REPLACEB and REPLACE as shown below.

replaceb function 3

Note: You should enclose the text string in an Excel formula with double quotes (""). Note that cell references, numbers or dates should not be within quotes.


Related functions

Excel REPLACE Function

The REPLACE function in Excel can help you to find and replace characters based on given location from text string with a new text. Take the below screenshot as example, replace 4 characters which start at the fifth character from the text string with another text string.

Excel SUBSTITUTE Function

The Microsoft Excel SUBSTITUTE function replaces text or characters within a text string with another text or characters.

Excel LENB Function

The LENB function returns the length of a string in bytes. LENB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.

Excel MIDB Function

The MIDB function returns a specific number of characters from a text string, starting at the position you specify, based on the number of bytes you specify. MIDB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.

Excel LEFTB Function

The LEFTB function returns the specified number of characters from the beginning (left) of a supplied string based on the number of bytes you specify. LEFTB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.

Excel RIGHTB Function

The RIGHTB function returns the specified number of characters from the end (right) of a supplied string based on the number of bytes you specify. RIGHTB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.


The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ...
Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup...
Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List...
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Description


Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations