Check Sheet Logo
Check Sheet

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.

Usage

Use the RIGHTB formula with the syntax shown below, it has 2 required parameters:

=RIGHTB(string, num_of_bytes)
Parameters:
  1. string (required):
    The text string that you want to extract bytes from.
  2. num_of_bytes (required):
    The number of bytes that you want to extract from the end of the text string.

Examples

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

Extract file extensions

You can use the RIGHTB function to extract file extensions from a list of filenames. For example, if you have a list of filenames in column A, you can use the formula =RIGHTB(A1,FIND(".",A1,1)) to extract the file extension from the filename in cell A1.

Truncate text to a certain length

You can use the RIGHTB function to truncate text to a certain length by extracting a specified number of bytes from the end of the text string. For example, if you have a text string in cell A1 that is longer than 10 bytes, you can use the formula =RIGHTB(A1,10) to extract the last 10 bytes of the text string.

Common Mistakes

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

Using number of characters instead of number of bytes

The RIGHTB formula returns the specified number of bytes, not characters. If the text string contains multi-byte characters, the number of characters and bytes will be different. Make sure to use the number of bytes when specifying the length of the substring to extract.

Specifying a negative number of bytes

The number of bytes specified in the formula must be a positive integer. If a negative number is specified, the formula will return an error.

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

  • 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.

  • LENB

    The LENB function in Google Sheets is used to count the number of bytes in a given text string. This function is useful when working with double-byte character set (DBCS) languages, such as Chinese, Japanese, or Korean, where each character is represented by two bytes. The LENB function returns the number of bytes in a string, which will be twice the number of characters in the string if it contains only DBCS characters.

  • FIND

    The FIND formula in Google Sheets searches for a specific text within another text and returns the position of the first occurrence of the text. This formula is often used to extract a substring from a larger string or to check if a certain text exists within another text.

Learn More

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