REPLACEB(text, position, num_bytes, new_text)One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.
text:
The original text string that you want to modify.
position:
The position in the text string where the replacement will begin. The first character is at position 1.
num_bytes:
The number of bytes in the text string that you want to replace, starting from the specified position.
new_text:
The text that will replace the specified number of bytes in the original text string.
The REPLACEB function in Google Sheets is a text manipulation tool that allows you to replace a specified number of bytes in a string with another string. This function is particularly useful when dealing with multi-byte character sets, such as those used in languages like Chinese, Japanese, or Korean. Unlike the standard REPLACE function, REPLACEB counts bytes instead of characters, making it more suitable for certain applications.
In simpler terms, REPLACEB enables you to modify specific parts of a text string based on byte length, which can be crucial for accurate text processing in various languages.
Imagine you are working with a list of product descriptions in a Google Sheets document:
| ProductID | Description |
|---|---|
| 101 | Widget A - High Quality |
| 102 | Widget B - Affordable |
| 103 | Widget C - Best Seller |
You want to replace the phrase "High Quality" in the description of Widget A with "Premium Quality".
To achieve this, you would use the REPLACEB function as follows:
=REPLACEB(B2, FIND("High Quality", B2), LEN("High Quality"), "Premium Quality")In this formula:
B2 is the cell containing the original description.FIND("High Quality", B2) locates the starting position of the text you want to replace.LEN("High Quality") calculates the number of bytes to replace."Premium Quality" is the new text that will replace the old text.When you apply the REPLACEB formula to the Product Descriptions Table, the output would look like this:
| ProductID | Description |
|---|---|
| 101 | Widget A - Premium Quality |
| 102 | Widget B - Affordable |
| 103 | Widget C - Best Seller |
In this case, the description for Widget A has been successfully updated to reflect the new phrase.
REPLACEB is beneficial because it provides a way to manipulate text based on byte length, which is essential for handling multi-byte characters accurately. This function simplifies the process of modifying text strings without the risk of miscalculating character lengths, especially in languages that use more complex character sets.
REPLACEB is an essential function for anyone working with text data in Google Sheets, providing a powerful way to enhance text processing capabilities.
Happy spreadsheeting!
You have a list of product codes in Column A and need to update them by removing the last two characters. Use the REPLACEB formula to modify the codes in Column B, ensuring accurate inventory tracking without manually editing each entry.
Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.
Browse our complete library of Google Sheets formula guides
Compare your options
Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.
AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.