Description
Use this function to return a specified number of characters from the end of a text string. Supported in Chains.
Syntax
RIGHT(text, [num_chars])
Inputs
This function accepts the following arguments:
| Name | Required | Description | Valid input |
|---|---|---|---|
text |
Yes | The text string from which you want to extract characters. | A cell reference, a number, a text string, or a formula which results in any of these. |
num_chars |
No | The number of characters you want to extract from the start of the text. | A positive integer, a cell reference containing a positive integer, or a formula which results in either of these. If omitted, defaults to 1. |
Example
Sample data
| A | B |
|---|---|
| 1 | Workiva |
| 2 | 01 (123) 456-7890 |
| 3 | John Doe |
| 4 | ABC123 |
| 5 May 2024 | 4/6/2024 |
| eggplant | The quick brown fox |
Sample Formulas
| Formula | Description | Result |
|---|---|---|
=RIGHT(B1, 5) |
Returns the last 2 characters from cell B1. | plant |
=RIGHT(B2,8) |
Extracts the phone number portion from the phone number in cell B2. | 123 |
=RIGHT(B3, FIND(" ", B3)-1) |
Returns the last name from the full name in cell B3. | John |
=RIGHT(B4) |
Returns the rightmost character from cell B4. | 3 |
=RIGHT(B1, 10) |
Attempts to return 10 characters, but B1 has only 8. | Workiva |
=RIGHT(B5, A4) |
Returns the last n characters from cell B5 using the value in cell A4 as the value for n. In this case, as this is a date, this will be the last 4 digits of the Julian date. | 5447 |
=RIGHT(A5, 8) |
Returns the rightmost 8 characters from cell A5. This date is in text format. | May 2024 |
=RIGHT(B1, LEN(B1)-3) |
Returns all but the first 3 characters from cell B1. | kiva |
=RIGHT(A2, FIND(" ", A2,LEN(A2)-LEN(SUBSTITUTE(A2, " ", "")))-1) |
Returns all but the last word. | fox |
Notes
- If
num_charsis greater than the length of text, RIGHT returns the entire text. - If
num_charsis omitted, RIGHT defaults to 1, returning only the last character. - If
num_charsis 0, RIGHT returns a blank cell. - RIGHT treats each character, including spaces and punctuation, as one unit.
- For non-text inputs, RIGHT attempts to convert the value to text before processing.
- RIGHT can be nested within other functions or combined with other text functions for more complex text manipulation.
Tips
- Combine RIGHT with LEN to extract all but the first n characters of a string.
- Combine RIGHT with FIND or SEARCH to extract substrings up to a specific character or delimiter.
- When working with dates stored as text, use RIGHT to extract the year or month.
- For extracting characters from the start of a string, use LEFT instead.
- Combine RIGHT with SUBSTITUTE to remove unwanted characters from the end of a text string.
Related functions
CHAR
CODE
CONCATENATE
CONCATENATEIF
FIND
LEFT
LEN
LOWER
MID
PROPER
REPT
RIGHT
SEARCH
SUBSTITUTE
TEXT
TEXTJOIN
TRIM
UNICHAR
UNICODE
UPPER