Google Sheets REPLACEB Function: Syntax, Examples & Tips

The REPLACEB function replaces part of a text string with another string, based on specified byte positions.
Google Sheets
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.

On this page
  1. Parameters
  2. What is a REPLACEB Function?
  3. A Practical Example
  4. REPLACEB Formula
  5. Result of the Formula
  6. Why Use REPLACEB?
  7. Key Takeaways:
  8. Example use case

Parameters

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.

What is a REPLACEB Function?

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.

A Practical Example

Imagine you are working with a list of product descriptions in a Google Sheets document:

Product Descriptions Table:

ProductIDDescription
101Widget A - High Quality
102Widget B - Affordable
103Widget C - Best Seller

You want to replace the phrase "High Quality" in the description of Widget A with "Premium Quality".

REPLACEB Formula

To achieve this, you would use the REPLACEB function as follows:

Google Sheets
=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.

Result of the Formula

When you apply the REPLACEB formula to the Product Descriptions Table, the output would look like this:

ProductIDDescription
101Widget A - Premium Quality
102Widget B - Affordable
103Widget C - Best Seller

In this case, the description for Widget A has been successfully updated to reflect the new phrase.

Why Use REPLACEB?

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.

Key Takeaways:

  • REPLACEB: A Google Sheets function that replaces a specified number of bytes in a text string.
  • Byte Counting: Specifically designed for multi-byte character sets, ensuring accurate text manipulation.
  • Text Modification: Ideal for updating product descriptions, names, or any text where precise byte control is necessary.
  • Common Use Cases: Useful in applications involving internationalization, where text may include characters that require more than one byte.

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!

Example use case

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.

Need more help with Google Sheets formulas?

Sign up for Better Analyst and get unlimited AI-powered formula generation, explanations, and advanced data analysis.

Explore all Google Sheets formulas

Browse our complete library of Google Sheets formula guides

Compare your options

Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

  1. 01ChatGPTOpen a balanced comparison prompt in ChatGPT.
  2. 02ClaudeOpen the same research prompt in Claude.
  3. 03PerplexityResearch the comparison with linked web sources.

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.