CLEAN UP TEXT RIGHT Function in Excel and Goo… Extract a specified number of characters from the end… Excel 2003+ Google Sheets Same syntax Microsoft Excel B2 =RIGHT(text, [num_chars]) A B Filename Extension 2 report.pdf .pdf 3 budget.xlsx .xlsx 4 photo.jpeg .jpeg
Learning Hub Functions Clean Up Text

RIGHT Function in Excel and Google Sheets

Clean Up Text 📊 Excel 2003+ ✓ Google Sheets Same syntax in both apps
Purpose
Extract a specified number of characters from the end of a text string
Return value
A text string containing the rightmost num_chars characters of the text argument
RIGHT is the mirror of LEFT -- where LEFT pulls characters from the start of a string, RIGHT pulls them from the end. I use it whenever the meaningful part of a text value is at the right side: file extensions like .xlsx or .pdf, country calling codes at the end of a phone number format, the last four digits of a reference code, the domain suffix at the end of an email address. When the number of characters to extract is always the same, RIGHT is a simple two-argument formula. When the suffix length varies -- because it ends at a delimiter -- combining RIGHT with LEN and FIND gives you a dynamic extraction that adapts row by row. RIGHT is part of the LEFT, RIGHT, and MID trio that together handle all fixed-position text extraction in a spreadsheet, and understanding all three gives you a complete toolkit for any text-parsing task you will encounter.
Syntax
✓ Excel 2003+ ✓ Google Sheets = Same syntax
=RIGHT(text, [num_chars])
num_chars defaults to 1 if omitted.
Arguments
ArgumentRequiredDescription
text Required The text string to extract from. Can be a cell reference, a literal string in quotes, or a formula result. Numbers are treated as text.
num_chars Optional The number of characters to extract from the right end. Must be zero or positive -- negative values cause #VALUE!. Defaults to 1 if omitted. If larger than the string length, the full string is returned.
How it works
RIGHT counts characters from the last position in the text string -- position 1 is the rightmost character. It returns num_chars characters working leftward from that position. Spaces, hyphens, and special characters all count as one character each. Like LEFT, the result is always a text string even when extracted characters look numeric -- wrap in VALUE if the result needs to participate in calculations. When the suffix length is fixed -- always 4 digits, always 3-character extension -- RIGHT needs only the text and the count. When the suffix starts after a delimiter whose position varies, combine RIGHT with LEN and FIND: the total string length minus the position of the delimiter gives the number of characters to extract from the right. For extracting from the start of a string, LEFT is the counterpart. For extracting from anywhere in the middle, MID with a start position is the right choice.
Examples
1
Extract the 3-character file extension from each filename in a list.
fx =RIGHT(A2,4)
A B
1 Filename Extension
2 report.pdf =RIGHT(A2,4)
3 budget.xlsx .xlsx
4 photo.jpeg .jpeg
5 notes.docx .docx
6 data.csv .csv
Row 2: .pdf — RIGHT("report.pdf",4) counts 4 characters from the right and returns .pdf -- the dot plus the three-letter extension.
Using 4 captures the dot as well as the three extension letters. If you only wanted the letters without the dot, use 3 instead. This fixed-length approach works when all extensions in your dataset have the same length.
2
Extract the variable-length domain from email addresses by finding the @ symbol and taking everything to the right of it.
fx =RIGHT(A2,LEN(A2)-FIND("@",A2))
A B
1 Email Domain
2 alice@gmail.com =RIGHT(A2,LEN(A2)-FIND("@",A2))
3 bob@company.co.uk company.co.uk
4 carol@outlook.com outlook.com
5 dan@mywork.org mywork.org
6 eve@yahoo.com yahoo.com
Row 2: gmail.com — FIND locates @ at position 6 in alice@gmail.com. LEN gives 15 total characters. 15-6 = 9 characters to extract from the right: gmail.com.
LEN minus FIND gives the number of characters after the delimiter. This dynamic calculation works for any email length -- bob@company.co.uk returns 13 characters and alice@gmail.com returns 9, both correctly.
3
Extract the last 4 digits of a reference code and convert the result to a number using VALUE.
fx =VALUE(RIGHT(A2,4))
A B
1 Reference Last 4 (numeric)
2 INV-2024-0042 =VALUE(RIGHT(A2,4))
3 INV-2024-1138 1138
4 INV-2023-0007 7
5 INV-2024-0500 500
6 INV-2024-9999 9999
Row 2: 42 — RIGHT extracts 0042 as the text string 0042. VALUE converts it to the number 42, dropping the leading zero. The numeric result can be used in comparisons and arithmetic.
VALUE strips leading zeros because numbers do not have leading zeros. If you need to keep 0042 as a formatted display value, keep it as text without VALUE. Only wrap in VALUE when you need the result to participate in arithmetic.
Common use cases
1. Extract a fixed-length file extension from a filename column
=RIGHT(A2,4)
2. Get the domain portion of an email address after the @ symbol
=RIGHT(A2,LEN(A2)-FIND("@",A2))
3. Extract the last N digits of a product or reference code for sorting or grouping
=RIGHT(A2,4)
4. Extract the country code suffix at the end of a structured identifier
=RIGHT(A2,2)
5. Get everything after the last slash in a file path or URL
=RIGHT(A2,LEN(A2)-FIND("*",SUBSTITUTE(A2,"/","*",LEN(A2)-LEN(SUBSTITUTE(A2,"/","")))))
Common errors
#VALUE! error
num_chars is negative, or FIND inside the formula cannot locate the delimiter and returns #VALUE! which propagates through RIGHT.
Fix: Ensure num_chars is zero or positive. Wrap FIND in IFERROR if the delimiter may not always be present: =IFERROR(RIGHT(A2,LEN(A2)-FIND("@",A2)),A2).
Result is text when a number is needed
RIGHT always returns a text string even when the extracted characters look numeric. Arithmetic or comparisons treat it as text.
Fix: Wrap in VALUE: =VALUE(RIGHT(A2,4)) converts the result to a real number. Only do this when calculation is needed -- not when the result is for display only.
Wrong characters extracted because of trailing spaces
The text has trailing spaces that shift the rightmost characters. The actual last character is a space, not the expected character.
Fix: Wrap the text argument in TRIM: =RIGHT(TRIM(A2),4) removes trailing spaces before RIGHT counts from the end.
Tips and variations
Combine with LEN and FIND for variable-length suffix extraction
When the suffix starts at a delimiter whose position varies by row, LEN(A2)-FIND(delimiter,A2) gives the character count to pass to RIGHT. This dynamic approach adapts to every row without manual measurement.
=RIGHT(A2,LEN(A2)-FIND("@",A2))
Wrap in VALUE when the result feeds calculations
RIGHT returns text. Add VALUE around the formula whenever the extracted characters will be used in arithmetic, date functions, or numeric comparisons. Without it, Excel treats even digit-only results as text strings.
=VALUE(RIGHT(A2,4))
Use TRIM on imported data before extracting
Data from external sources often has trailing spaces. RIGHT then extracts the space as one of its characters, giving wrong results. TRIM on the input fixes this before RIGHT counts from the end.
=RIGHT(TRIM(A2),4)
Excel vs Google Sheets
Excel vs Google Sheets
RIGHT works identically in Excel 2003 and newer and every version of Google Sheets. Character counting, behaviour when num_chars exceeds the string length, and text-only output are the same in both applications. Formulas copy between them without changes.
Related reading
Frequently asked questions
RIGHT extracts a specified number of characters from the end (right side) of a text string. =RIGHT("Hello",3) returns llo. It is used to extract file extensions, country or area codes at the end of identifiers, the last few digits of a reference number, or any fixed-length suffix.
LEFT extracts characters from the start of the string. RIGHT extracts from the end. MID extracts from any position in the middle -- you specify the start position and the length. Use RIGHT for suffixes and endings, LEFT for prefixes, and MID for anything in between those positions.
Use LEN and FIND together: =RIGHT(A2,LEN(A2)-FIND(".",A2)) extracts everything after the first period. LEN gives the total length and FIND gives the position of the delimiter -- subtracting one from the other gives the length of the suffix to extract with RIGHT.
RIGHT treats its input as text. If A2 contains the number 12345, =RIGHT(A2,2) returns the text string 45, not the number 45. If the result needs to be numeric for calculations, wrap in VALUE: =VALUE(RIGHT(A2,2)).
RIGHT returns the entire string without any error. =RIGHT("Hello",100) returns Hello -- all five characters -- because RIGHT simply stops at the beginning of the string. This makes RIGHT safe to use with a large num_chars as a safe overcount when you want everything from the right side of a short string.