RIGHT - Extract a suffix and preserve leading zeroes
Read invoice serials from the end of a code and keep digit identifiers as text rather than accidentally shortening them.
By the end, you can
- Take characters from the end.
- Preserve digit strings such as 0042.
- Use LEN for a variable-length remainder.
Before you start: Understand text extraction and cell references.
In this lesson
The end of a code can be the reporting key
RIGHT extracts characters from the end of text. Accounts can isolate a four-character invoice serial while keeping the full invoice code in the source column. It returns text: a serial of 0042 remains four characters, unlike the number 42. Trailing spaces also count, so inspect messy exports before choosing a length.
Syntax and arguments
=RIGHT(text, [num_chars])The optional length defaults to one character from the end.
| Argument | Purpose | Example |
|---|---|---|
textRequired | The source string or cell. | A2 |
num_charsOptional | How many ending characters to extract. | 4 |
Four-character invoice serials
0042| A | B | |
|---|---|---|
| 1 | Invoice | Serial as text |
| 2 | INV-0042 | 0042 |
| 3 | INV-5903 | 5903 |
| 4 | INV-6714 | 6714 |
=RIGHT(A2,4)Read the final four characters of INV-0042, preserving both leading zeroes.
- Verify that each serial has four characters, regardless of its numeric appearance.
- Enter =RIGHT(A2,4) beside the source.
- Fill down to use A3 and A4.
- Confirm the first output remains 0042, not 42.
Short suffixes and variable remainders
=RIGHT(A2)The omitted length defaults to one; the final character is 2.
=RIGHT(A2,2)Extract 42 as a text suffix, not as a calculation.
=RIGHT(A2,LEN(A2)-4)The source has eight characters. After removing the four-character prefix, keep its four-character remainder.
Important boundaries and compatibility
- A count longer than the source returns the available text. Zero returns empty text; a negative count produces #VALUE!.
- RIGHT preserves the remaining text's order; it does not reverse characters.
- Numeric source values are converted to text for extraction, but display formatting is not a reliable way to supply leading zeroes or formatted dates. Store identifiers as text.
- RIGHT is available in older/current Excel. Workbook Compatibility Version can affect character positions for Unicode surrogate pairs; ASCII examples avoid that distinction.
Common mistakes and Practice scope
The invoice challenge tests ASCII suffixes. The separate order-prefix challenge combines RIGHT with LEN for a remainder whose length varies; neither verifies desktop Excel's Unicode-version behavior.
Check your understanding
Choose an answer for instant feedback. You can try again; answers stay only on this page.