RIGHTB

    Text

    Returns the rightmost characters of a text string based on a number of bytes. Each double-byte character (DBCS) counts as 2 bytes; single-byte characters count as 1.

    Translations
    EnglishRIGHTB
    FrenchDROITEB
    SpanishDERECHAB
    GermanRECHTSB
    ItalianDESTRAB
    PortugueseDIREITAB
    DutchRECHTSB
    PolishPRAWYB
    RussianПРАВСИМВБ
    TurkishSAĞDANB
    CzechZPRAVAB
    HungarianJOBBB
    SwedishHÖGERB
    DanishHØJREB
    FinnishOIKEA.B
    Syntax
    RIGHTB(text, [num_bytes])

    Arguments

    • textThe text from which to extract the rightmost characters.
    • num_bytesThe number of bytes to extract (default 1). Must be ≥ 0.(optional)
    Examples
    =RIGHTB("Excel",3)
    cel

    Returns the last 3 bytes

    =RIGHTB("日本語",2)

    1 double-byte character = 2 bytes

    =RIGHTB("AB日本",4)
    日本

    2 double-byte characters = 4 bytes

    Tips & Best Practices
    • On systems without DBCS support, RIGHTB behaves like RIGHT
    • Use RIGHT to extract by character count instead of byte count
    • Mainly used in East Asian Excel installations
    Common Mistakes
    • Using RIGHTB when RIGHT (character-based extraction) is actually what's needed - RIGHTB counts bytes, so a num_bytes value that seems right by character count can cut a double-byte character in half
    • Assuming num_bytes always corresponds directly to a whole number of characters - with double-byte text, an odd num_bytes value can split a single character, producing a garbled or unexpected result
    • Forgetting that on systems without double-byte character set support, RIGHTB simply behaves like RIGHT, so testing on a Western-locale machine can hide bugs that only appear with East Asian text
    Related Functions
    RIGHTExtracts by character count instead of byte count, the correct choice for text that doesn't need double-byte-aware handling.
    LEFTBPerforms the same byte-based extraction as RIGHTB but from the beginning of the string instead of the end.
    MIDBExtracts from any starting byte position, a more flexible version of the same byte-counting logic RIGHTB uses.
    Frequently Asked Questions

    Why did RIGHTB cut off part of a character instead of a clean substring?

    num_bytes probably fell in the middle of a double-byte character counted from the end - since each such character occupies 2 bytes, an odd byte count can split one in half, producing a garbled result.

    Should I use RIGHT or RIGHTB?

    Use RIGHT for ordinary character-based extraction. Reach for RIGHTB only when you specifically need byte-based counting, such as matching a legacy system's storage limits for East Asian text.

    Does RIGHTB work the same as RIGHT on a system without double-byte language support?

    Yes, in that case there's no distinction between characters and bytes, so RIGHTB and RIGHT return identical results.

    Need to translate a formula using RIGHTB?

    Use our translator to convert your complete formula