Excel RIGHT function
If you want to extract a specific number of characters from the right side of the text string, the RIGHT function maybe the best choice for you. This article, I will talk about how to use the RIGHT function in Excel workbook.
- Example 1: Extract the last x characters from the text strings with RIGHT function
- Example 2: Extract the substring after a specific separator with RIGHT function
- Example 3: Remove the first n characters from text strings with RIGHT function
The syntax for the RIGHT function in Excel is:
Return the text from right of the text string.
To extract the last 4 characters from the text strings, please apply the following formula:
Then, drag the fill handle down to the cells that you want to apply this formula, and all the last 4 characters have been extracted at once, see screenshot:
For example, I need to extract the substrings after the delimiter-hyphen, comma, space or other separators, the RIGHT function can do you a favor.
Please apply the below formula into a blank cell:
Note: In the above formula, A2 is the cell that you want to extract text, “-” is the specific character that you want to extract substring based on, you can change it to other separators as you need.
Then, drag the fill handle down to fill this formula to other cells, and all the substrings after the specific separator have been extracted as below screenshot sown:
Tips: Sometimes, if there are more than one separators within the text stings, and you want to extract the substring from last occurrence of the delimiter as below screenshot:
To solve this task, please apply the following formula:
And, you will get the text after the last occurrence of the hyphen, see screenshot:
With this RIGHT function, you can also remove first x characters from left of the text strings as below screenshot shown.
For solving this job, please use the following formula:
Note: In the above formula, A2 is the cell value that you want to remove characters; The number 2 means the number of characters you want to remove from the beginning of the text string.
Then, drag the fill handle down to the cells you want to apply this formula, and all the first two characters are removed from the right side of the text strings:
- Excel MID Function
- MID function is used to extract the specific characters from the middle of text string.
- Excel LEFT Function
- The LEFT function extracts the given number of characters from the left side of a supplied string.
- Excel SEARCH Function
- The SEARCH function can help you to find the position of a specific character or substring from the given text string.