Text function

RIGHTB function

Returns the last characters of a text up to a given number of bytes; CJK characters count as 2 when a DBCS language is the default.

Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web

In every Excel versionWorks in Google Sheets

Syntax

RIGHTB(text, [num_bytes])
ArgumentWhat it means
textRequiredThe text or cell.
num_bytesOptionalHow many bytes to return from the end. Default 1.

Returns: Text: the trailing characters that fit into num_bytes.

How RIGHTB works

RIGHTB is the byte-counting version of RIGHT. In the legacy double-byte character sets used for Japanese, Chinese and Korean, each kanji, kana or hangul character takes 2 bytes, while Latin letters and digits take 1. When a file layout or system limit is expressed in bytes, RIGHTB extracts the right amount of text from the end of a value.

Byte counting only happens when a double-byte (DBCS) language - Japanese, Chinese (Simplified or Traditional) or Korean - is set as the default editing language under File > Options > Language. With any other default language every character counts as 1 byte and the B version behaves exactly like the normal one.

Like the other B functions, it cannot return half a character: if the byte count would split a double-byte character, the result is adjusted.

Examples

1Last two kanji of an address (Japanese default language)

B2fx=RIGHTB(A2,4)
AB
1Address
2東京都港区港区

Result: 港区

Four bytes from the end hold two double-byte characters.

2Mixed text (Japanese default language)

B2fx=RIGHTB(A2,5)
AB
1Code
2東京ABC京ABC

Result: 京ABC

ABC gives 3 bytes and 京 the other 2. RIGHT(A2,5) would return the whole text.

3English default language

B2fx=RIGHTB(A2,4)
AB
1Address
2東京都港区京都港区

Result: 京都港区

Without a DBCS default language each character is 1 byte, so the last 4 characters are returned, just like RIGHT.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!num_bytes is negative.Use 0 or a positive number.

Tips

  • Combine with LENB to drop a fixed number of bytes from the start: =RIGHTB(A2,LENB(A2)-6).
  • For everyday text work use RIGHT, which behaves the same on every computer.

Google Sheets

RIGHTB also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

RIGHTB in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
FrenchDROITEB
GermanRECHTSB
PolishPRAWY.B
RussianПРАВБ
SpanishDERECHAB