How to extract part of text string from cell in Excel?
This tutorial demonstrates methods to extract substrings from the left, middle, or right of a cell and explains how to extract text before or after a specific character, as shown in the screenshots below.
Method A: Extract substring from left, middle or right by using formula
In Excel, there are some formulas can help you to quickly extract part of text.
Extract first n characters
Supposing you want to extract first 3 characters from a given list data, please select a blank cell that you want to place the extracted result, then use this formula
B3 is the cell you extract characters from, 3 is the number of characters you want to extract.
Press Enter key to get the extracted result. Then drag fill handle over the cells to apply this formula.
Extract last n characters
For example, extract last 6 characters from a list of string, please select a blank cell that you want to place the extracted result and use this formula:
B9 is the cell you extract characters from, 6 is the number of characters you want to extract.
Press Enter key to get the extracted result. Then drag fill handle over the cells to apply this formula.
Extract n characters from the middle
If you want to extract 3 characters begin from the 4th character of a string, you can use below formula:
B15 is the cell you extract characters from, 4 represent extract characters from 4th character (count from left), 3 is the number of characters you want to extract.
Press Enter key to get the extracted result. Then drag fill handle over the cells to apply this formula.
Note: If you want to move the extracted results to another location, please copy and paste the extracted results as value firstly.
Method B: Extract substring from left, mid or right by Kutools for Excel
If you are not familiar with formulas, you can try Kutools for Excel’s Extract Text feature which is easy to handle this job.
1. Select the cells that you want to extract substrings from, click Kutools > Text > Extract Text.
2. In the popping Extract Text dialog, under the Extract by location tab, the first three options support you to extract substring from left, mid or right.
The first N character: extract substring from left. For instance, extract first 2 characters, check this option and type 2 into textbox.
The last N character: extract substring from right of the string. For instance, extract last 2 characters, check this option and type 2 into textbox.
Start to end characters: extract specific number of characters from middle for string. For instance, extract from 4th character to 9th character, check this option and type 4 and 9 into textboxes separately.
Insert as a formula: check this checkbox, the result is a formula which can be changed as the original string change, otherwise, the result is fixed.
3. After specifying the location as you need, click Ok, a dialog pops out to select a cell to place the extracted substring. Click OK.
Now the substring has been extracted.
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
If you want to extract a substring after or before a specified character, you can apply one of the methods below to complete the task.
Method A: Extract substring after or before a defined character by using formula
Supposing you want to extract characters after the character “-” from a list of strings, please use this formula:
B3 is the cell you want to extract characters from, - is the character you want to extract string after.
Press Enter key to get the extracted result. Then drag fill handle over the cells to apply this formula.
If you want to extract substring before a defined character, you can use the formula like this:
Example result is shown as below:
Note:
The data may be lost or changed while you copy and paste the formula results to another location. For preventing this problem from happening, you can copy and paste the formula results as value after applying the formula. Or you can try the Method B.
Method B: Extract substring after or before a defined character by Kutools for Excel
To directly extract a substring after or before a specified character, you can use the Extract Text utility of Kutools for Excel, which can help you to extract all characters after or before a character, also can extract specific length of characters before or after a character.
1. Select the cells that you want to extract characters, click Kutools > Text > Extract Text.
2. In the popping Extract Text dialog, under Extract by location tab, go to the before the text and after the text options to specify the setting as you need..
Before the text: extract substrings before the entered character(s). For instance, type – into the textbox, all characters before – will be extracted.
After the text: extract substrings after the entered character(s). For instance, type – into the textbox, all characters after – will be extracted.
Insert as a formula: check this checkbox, the result is a formula which can be changed as the original string change, otherwise, the result is fixed.
3. Click Ok, a dialog pops out to select a cell to place the extracted substring. Click OK.
Now the string before or after the certain character(s) has been extracted.
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
Maybe in some cases, you need to extract substring between two characters, you can choose one of below methods to handle the job.
To extract characters between brackets () from a given list, you can use below formula:
In the formula, B3 is the cell that you want to extract string from, ( and ) are the two characters you want to extract string between.
Press Enter key to get the extracted result. Then drag fill handle over the cells to apply this formula.
Note: If the formula is a little difficult for you, you can try the Method B, which is using a handy tool to quickly solve this problem.
Method B: Extract by Kutools for Excel
In Kutools for Excel’s hundreds of features, there is a feature – Extract strings between specified text can quickly extract substrings between two characters.
1. Select a cell that used to place the extracted substring, click Kutools > Formula Helper > Text > Extract strings between specified text.
2. In the Formulas Helper dialog, go to the Arguments input section, then select or directly type the cell reference and the two characters you want to extract between.
By default, when you select the cell reference used for extracting the substring, it will be absolute, preventing the use of the auto-fill handle. Please change it to relative.
3. Click Ok, now the first result has been gotten, then drag auto fill handle over cells that need this formula.
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
Tip: If you want to extract strings between two characters (including the two characters), the Extract Text utility of Kutools for Excel also can help. Please do as follows:
1. Select the cells that you want to extract substring between characters, click Kutools > Text > Extract Text.
2. In the popping Extract Text dialog, under Extract by rule tab, go to the Text section, type the characters that you want to extract string between, and the string can be repented by the wildcard *. If you want to extract string with fixed length, the wildcard ? can be used, one ? indicate one character.
Click Add to include the rule in the Rule description section.
3.Click Ok, a dialog pops out to select a cell to place the extracted substring. Click OK.
The string between two specified characters is now extracted.
If you want to extract e-mail address from a given string or a range of cells, you can use the Extract Email Address function to handle this job at once time instead of finding them one by one.
1. Select the cells that will be extracted email address, then click Kutools > Text > Extract Email Address.
2. Then a dialog pops out for you selecting a cell to output the address emails.
3. Click OK, the email addresses in each cell have been extracted.
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
If your data includes a mix of numeric, alphabetical, and special characters, and you only want to extract the numbers or alphabetical values, try Kutools for Excel's Remove Characters utility.
1. Before using the Remove Characters utility, make a copy of the data as shown in the screenshot below.
2. Then select this copy of data, click Kutools > Text > Remove Characters.
3. In the Remove Characters dialog, check Non-numeric option, click Ok.
Now, only the numeric characters remain.
To extract alphabetical values only, check Non-alpha option in the Remove Characters dialog.
Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now
Click to download this sample file
Extract time from datetime string
Provides tricks to extract time (hh:mm:ss) or hour/minute/second only from datetime string (mm/dd/yyyy hh:mm:ss)
Extract rows that meet criteria
In this article, it can help you quickly extract these rows that meet criteria to another location in Excel except finding and copying them one by one.
Extract a nth character from string
Here will introduce the methods on extracting the nth character from a string, for example, extract the 3th character from string a1b2c3, the result is b.
Extract substring between two characters
Show the methods on extracting substring between two same or different characters.
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!