Check Sheet Logo
Check Sheet

REPLACEB

The REPLACEB function in Google Sheets replaces a specified number of bytes in a text string, starting at a specific position, with a new text. This function is mostly used to substitute part of a text string with a new text. It is similar to the REPLACE function, but it supports double-byte characters.

Usage

Use the REPLACEB formula with the syntax shown below, it has 4 required parameters:

=REPLACEB(text, position, num_bytes, new_text)
Parameters:
  1. text (required):
    The text string from which you want to replace characters.
  2. position (required):
    The position of the first byte you want to replace in the text string.
  3. num_bytes (required):
    The number of bytes you want to replace in the text string.
  4. new_text (required):
    The new text that you want to replace the old text with.

Examples

Here are a few example use cases that explain how to use the REPLACEB formula in Google Sheets.

Replace part of a text string

You can use REPLACEB to substitute a specific part of a text string with a new text. For example, you can replace the first 3 bytes of a text string with a new text.

Remove double-byte characters

You can use REPLACEB to remove specific double-byte characters from a text string. For example, you can remove all occurrences of the double-byte character "あ" from a text string.

Replace part of a text string based on a condition

You can use REPLACEB in combination with other functions, such as IF, to replace part of a text string based on a specific condition. For example, you can replace part of a text string with a new text only if the text string contains a certain word.

Common Mistakes

REPLACEB not working? Here are some common mistakes people make when using the REPLACEB Google Sheets Formula:

Position is less than 1

The position argument must be greater than or equal to 1. If it is less than 1, REPLACEB returns an error.

Num_bytes is negative

The num_bytes argument must be a positive number. If it is negative, REPLACEB returns an error.

Position is greater than the length of the text string

If the position argument is greater than the length of the text string, REPLACEB returns the original string without any changes.

The following functions are similar to REPLACEB or are often used with it in a formula:

  • REPLACE

    The REPLACE formula is used to replace a specified number of characters, starting from a specified position, in a text string with new text. It is commonly used to replace or remove specific characters or words from a text string.

  • SUBSTITUTE

    The SUBSTITUTE formula is used to replace specific text in a string with new text. It is commonly used to replace all occurrences of a certain word or character within a larger string. The formula has the option to specify which occurrence to replace, or it will replace all occurrences by default.

  • LEFTB

    The LEFTB formula is used to extract a specified number of bytes from the beginning of a text string. This formula is similar to the LEFT formula, but instead of counting characters, it counts bytes. This can be useful when working with languages that use multi-byte characters, such as Chinese or Japanese.

  • RIGHTB

    The RIGHTB function returns a specified number of bytes from the end of a text string. This function is useful when working with non-Latin languages, where a character may be represented by multiple bytes. It is commonly used to extract file extensions or to truncate text to a certain length. The function is case-sensitive.

Learn More

You can learn more about the REPLACEB Google Sheets function on Google Support.