Right
RIGHT Function¶
The RIGHT function in Excel is a text function that allows users to extract a specified number of characters from the
end (right side) of a text string. It is useful when you want to extract a portion of a string based on its position
from the right.
Syntax:¶
RIGHT(text, [num_chars])
- text: The text string from which you want to extract characters. This can be a direct string, a cell reference, or the result of another function.
- num_chars (optional): The number of characters to extract starting from the right side of the string. If omitted, it defaults to 1, meaning only the last character will be extracted.
Key Details:¶
- If
num_charsis greater than the length of the text string, theRIGHTfunction will return the entire string without any error. - If
num_charsis set to 0, the result will be an empty string (""). - If
num_charsis negative or not an integer, Excel will return a#VALUE!error.
Examples:¶
-
Extracting the Last Three Characters:
This formula will return "cel", which are the last three characters of the text "Excel". -
Default Behavior (Extracting the Last Character):
Sincenum_charsis omitted, the formula will return "l", the last character of the text string "Excel". -
Using a Cell Reference:
will return "123", extracting the last 3 characters from the value in cell A1.
If cell A1 contains the text "Product123", the formula: -
Combining with Other Functions:
This formula extracts all characters after a hyphen ("-") in a string. It calculates the number of characters to extract based on the position of the hyphen.
You can useRIGHTin combination with other functions. For example: -
Using RIGHT for Substring Matching:
This formula filters the range A1:A10 to include only entries where the last 3 characters of the text are "123". -
Handling Too Many Characters:
will return "Excel" even though the text string contains fewer than 10 characters.
If you try to extract more characters than are available in the string, theRIGHTfunction will still return the full string. For example:
Notes:¶
- The
RIGHTfunction is case-sensitive and returns the characters exactly as they appear in the text string. - It is commonly used in data parsing tasks, such as extracting file extensions, suffixes, or parts of product codes.
By combining RIGHT with other functions like LEN and FIND, you can perform advanced text string manipulations with
ease.