- text - The text from which to extract characters on the right.
- num_chars - [optional] The number of characters to extract, starting on the right. Optional, default = 1.
The RIGHT function extracts a given number of characters from the right side of a supplied text string. The second argument, called num_chars, specifies the number of characters to extract. If num_chars is not provided, it defaults to 1. If num_chars is greater than the number of characters available, RIGHT returns the entire text string.
In the example below, we extract the state code "OR" (Oregon) from the string "Portland, OR"
=RIGHT("Portland, OR",2) // returns "OR"
If the optional argument num_chars is not provided, it defaults to 1:
=RIGHT("ABC") // returns "C"
If num_chars exceeds the string length, LEFT returns the entire string:
=RIGHT("apple",100) // returns "apple"
When LEFT is used on a numeric value, the result is text:
=RIGHT(1200,3) // returns "200" as text
The RIGHT function is often combined with other functions like LEN and FIND to extract text in more complex formulas. For example, to extract text in cell A1 to the right of a specific character (char), use RIGHT with the FIND and LEN functions like this:
=RIGHT(A1,LEN(A1)-FIND(char,A1)) // text to right char
FIND returns the position of the character, and RIGHT returns the text to the right of that position. Full explanation here.
The RIGHT function is used to extract text from the right side of a text string. Use the LEFT function to extract text starting from the left side of the text, and the MID function to extract from the middle of the text. The LEN function returns the length of text as a count of characters.
- num_chars is optional and defaults to 1.
- RIGHT will extract digits from numbers as well as text.
- Number formatting is not counted or extracted.