Category: FUNCTION | Updated: 2026-11-22
How to Use the RIGHT Function in Google Sheets | Extract Characters from the End of Text
How to Use the RIGHT Function
The RIGHT function extracts a specified number of characters from the end (right side) of a text string. It is useful for extracting the last 4 digits of a phone number or the sequential portion of an ID code.
Syntax
=RIGHT(string, [number_of_characters])
- string: The source text string or cell reference to extract from (required).
- number_of_characters: The number of characters to extract from the end as a positive integer (optional). If omitted, it defaults to
1(the last character only).
Example Using a Table
Here is an example of extracting the last 4 digits from the phone number list below.
| Row | Column A (Phone Number) | Column B (Result: Last 4 Digits) |
|---|---|---|
| 1 | Phone Number | Last 4 Digits |
| 2 | 090-1234-5678 | =RIGHT(A2, 4) → 5678 |
| 3 | 080-9876-5432 | =RIGHT(A3, 4) → 5432 |
| 4 | 03-1111-2222 | =RIGHT(A4, 4) → 2222 |
- Formula:
=RIGHT(A2, 4) - Result:
5678
Even when area code lengths differ, you can accurately extract the end of the string as long as the number of characters from the right is consistent.
Common Errors and Notes
- Negative Character Count Causes
#VALUE!: Passing a number less than0as the second argument returns a#VALUE!error. - Trailing Spaces Are Counted as Characters: If pasted data has trailing spaces at the end, those spaces are counted, which can cut off a character you wanted. Cleaning the text with
TRIMbefore extracting avoids this issue. - Extracted Result Is Text: Even if you extract only digits, the output is a text string. Wrap it in
VALUEwhen you need to compare or calculate with it as a number.
Frequently Asked Questions
Q. Can I use RIGHT to extract file extensions like .pdf or .csv from filenames?
A. If the extension has a fixed length (such as 3 characters), "=RIGHT(A2, 3)" works. When extension lengths vary, combine FIND or REGEXEXTRACT to extract everything after the last dot.
Q. What happens if I specify a character count larger than the original text in RIGHT?
A. No error occurs; the entire original text string is returned as is.