Excel RIGHTB Function
The RIGHTB function returns the specified number of characters from theend (right) of a supplied string based on the number of bytes you specify. RIGHTB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.
Syntax
=RIGHTB(text, [num_bytes])
Arguments
- text (required): The string you want to extract the given number of characters from its right side based on the specified num_bytes.
- num_bytes (optional): Specifies the number of bytes of characters to extract from the end (right) of the given text. If omitting this argument, it is assumed to be 1.
Return Value
The RIGHTB function returns specified number of characters.
Function Notes
- Spaces count as characters.
- If num_bytes is greater than the length of text, RIGHTB returns all of text.
- RIGHTB returns the #VALUE! error if num_bytes is negative.
- When you use RIGHTB to return double-byte characters, if num_bytes is an odd number, say 3, RIGHTB will only return the first double-byte character. You will have to add the num_bytes to 4 to return the first two double-byte characters.
- RIGHTB always counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, RIGHTB counts each character as 1 just like RIGHT.
- RIGHTB counts actual values instead of the look of your data. For example, A1 is date 9/1/2022, RIGHTB(A1,2) returns 05, as the actual value in A1 is 44805 which was just formatted as a date value.
Example
To have RIGHTB return specified numbers of characters from the start (right) of the supplied strings as shown in the below table, please copy or enter the formula below in the top cell (E6) of the result list, and press Enter to get the result. Then select the result cell, and drag the fill handle (the small square in the lower-right corner of the selected cell) down to apply the formula to the below cells.
=RIGHTB(B6,C6)
Instead of cell references, you can type the actual text and num_bytes values in the formula as shown below.
=RIGHTB("你在干什么",4)
Note: You should enclose the text string in an Excel formula with double quotes (""). Note that cell references, numbers or dates should not be within quotes.
RIGHTB VS. RIGHT
RIGHTB counts each double-byte character as 2 and each single-byte character as 1. While RIGHT counts both double- and single-byte character as 1. You can compare the results returned by RIGHTB and RIGHT as shown below.
Related functions
If you want to extract a specific number of characters from the right side of the text string, the RIGHT function maybe the best choice for you. This article, I will talk about how to use the RIGHT function in Excel workbook.
The LEFTB function returns the specified number of characters from the beginning (left) of a supplied string based on the number of bytes you specify. LEFTB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.
The REPLACEB function replaces part of a text string with a new text string based on the number of bytes you specify. REPLACEB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.
The LENB function returns the length of a string in bytes. LENB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.
The MIDB function returns a specific number of characters from a text string, starting at the position you specify, based on the number of bytes you specify. MIDB is intended for use with languages that use the double-byte character set (DBCS), such as Chinese (Simplified), Chinese (Traditional), Korean, and Japanese. The function counts each double-byte character as 2.
The Best Office Productivity Tools
Kutools for Excel - Helps You To Stand Out From Crowd
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
