Excel Substring Function (Table of Contents)
- Substring Function in Excel
- How to Use Substring Function in Excel?
- #1 – LEFT Substring Function in Excel
- #2– RIGHT Substring Function in Excel
- #3– MID Substring Function in Excel
Substring in Excel is a part of the text, it is not a particular function. If the text is India-123 then it is an alphanumeric string. India can be considered as a substring in the given string or text. Hence the substring function is just a part of the text in Excel.
The three integrated Text function of Excel helps to extract the substring which is LEFT, RIGHT and MID function.
In some cases, the excel substring Function can also be found with the help of FIND and SEARCH. The main objective is to find out the substring of the text, it does not matter how.
The LEFT, RIGHT, and MID functions are categorized under TEXT function which is inbuilt.
It helps us to:
- To get a string of any text.
- To find out a specifically required text of any string.
- To find out the position of any text in a string.
We can find these functions under the Formulas Tab.
Below is the screenshot for navigation purpose:
So, the above three are the most commonly used functions to find out the string for text.
How to Use Substring Function in Excel?
Substring function in Excel is very simple and easy to use. Let’s understand the working of Substring function in Excel by some examples.
4.8 (2,613 ratings)
#1 – LEFT Function in Excel
LEFT Function helps the user to know the substring from the left of any text. It starts counting with the leftmost character.
The syntax or formula for the LEFT function in Microsoft Excel is:
The LEFT function syntax or formula has the below-mentioned arguments:
- Text: This argument is compulsory as it represents the text from where we want to extract the characters or cell address.
- Num_chars: This one is an optional argument, which represents the number of characters from the left side of text or character, which we want to extract.
Extract a Substring in Excel Using LEFT Function
Suppose we want the first two characters or substring from the given example in below screenshot:
In the cell C4, a text is given from which we want the first two characters. We have to type =LEFT and then use ( or press Tab in D4, look at the screenshot for reference:
Now, we can see the argument required in the screenshot as well. We have to type or navigate the cell address to C4, and in place of num_chars, we need to put the number of character we want, so in this case, two characters are needed, so we put 2.
Below is the screenshot for the above step:
After putting an argument, we need to press ) or just press Enter to get the result. Below is the screenshot after completing the formula.
So, the result is Mr which is two characters of MrRam from left. To extract the substring from the left, we can use the LEFT function in excel.
Points to Remember while using LEFT Function in Excel
- The result or return value depends on the arguments which are inserted in the syntax.
- If the argument is less than (num_chars) 0, then the result would be a #VALUE error.
- The output or return value can be string or text.
- A LEFT function in excel is used for extracting the substring from the string, which calculates from the leftmost character.
#2 – RIGHT Function in Excel
RIGHT function from Text also helps to get the substring from the rightmost of a text. If we do not put number then it will show one character of rightmost.
The syntax or formula for the RIGHT function in Microsoft Excel is:
The RIGHT function syntax or formula has below-mentioned arguments:
- Text: It is the Text string that contains the characters where you want to extract.
- num_chars: It is the number of characters from the RIGHT side of the Text string you want to extract.
Extract a Substring in Excel Using RIGHT Function
Suppose we have to extract the last two characters of a word as shown in the below example:
Suppose we have to find out the last two character of D4 cell, then type =RIGHT in E4. Below is the screenshot for reference:
After that, we have to click on Tab or press (
We can see that the required argument is populating in the above screenshot. Accordingly, on the place of text, put cell address which is D4 here, and we want two 2 characters from right to put 2. Below is the screenshot for reference:
After putting all the argument close the formula by pressing ) or just hit Enter to know the result.
Hence, we can see in the above screenshot that 11 is populated after hitting Enter, the formula captures the last two characters from the right as entered in the argument. RIGHT Function helps to get the string from the right side of any character.
Points to Remember while using RIGHT Function in Excel
- The output depends on the syntax.
- The output will be a #VALUE error if the parameter is less than (num_chars) 0.
- The result can be a string as well as text.
#3 – MID Function in Excel
It helps us to extract a given number of characters from the middle of any string of text.
The syntax or formula for the MID function in Microsoft Excel is:
The MID function syntax or formula has the below-mentioned arguments:
- Text: It is the original text string or character from which we have to extract the substring or characters.
- Start_num: It indicates the position of the first character where we want to begin.
- num_chars: It is the number of characters from a middle part of the text string.
Like LEFT and RIGHT function, we can also use the MID function to get the substring of text in Excel.
Extract a Substring in Excel Using MID Function
Suppose, in below example we want to extract the three characters from the middle of the text then we can use MID Function.
We will see how to use MID Function to extract the string in middle in cell E5, step by step.
We have to type =MID and then press Tab or press ( like shown in below screenshot.
Now, we have to enter the arguments as shown in the above pic.
In place of text, we have to enter the cell address which is D5 here, start_num is the argument which defines from where we want the string, so in this case we want it from 6th from left and the last argument is num_chars, which defines about the number of character we want, so here it is 3.
So, in the screenshot, we can see that argument is put down as per requirement. After putting argument, close the formula with “)”, or just hit Enter to get the results. Below is the screenshot for reference.
So, we can see in the above screenshot that the TV7 is the result of MID Function applied. TV7 is the three characters from the 6th position of the text in an example.
Things to Remember about Substring Function in Excel
- Substring function is used to get the phone number or code as per requirement.
- It is also used to get the domain name of the email id.
- While using a substring in excel, the text function needs to be conceptually clear, to get the desired results.
- An argument should be put down in the formula as per the requirement.
This has been a guide to Substring Function in Excel. Here we discuss how to use Substrings functions in Excel – LEFT, RIGHT, and MID Function along with practical examples and downloadable excel template. You can also go through our other suggested articles –