The RIGHT function returns the given number of characters from the end of a string.
It allows you to work with text and retrieve the necessary parts of a string, which can be useful when processing data or creating reports.
Syntax
RIGHT(string, [num_characters])
Argument |
Description |
Admissible arguments |
|---|---|---|
string |
String from which the right fragment is returned |
Text string or reference to a cell containing text |
[num_characters] |
(optional) Number of characters to return from the end of the string. By default, 1 |
Integer ≥1 or a reference to a cell containing a number |
Examples of use
Retrieving characters from a string
If cell A1 contains the text “Hello” and you want to retrieve the last 3 characters:
=RIGHT(A1, 3)
The expression will return “llo” as these are the last 3 characters of the text.
Retrieving a single character
If you want to retrieve the last character from the string:
=RIGHT(A1)
The expression will return “o”, since this is the last character of the string.
Notes
–The RIGHT function works with any text strings and can be used to retrieve characters regardless of their type.
–If the num_characters exceeds argument the length of the string, the function will return the entire string.