How To Remove First, Last X Characters Or Certain Position Characters From Text In Excel?
Method 1: Remove first or last x characters from text strings with formulas
Method 2: Remove first or last x characters from text strings with User Defined Function
Method 3: Remove first, last x characters or certain position characters without any formulas
Method 4: Remove both first x and last x characters from text strings with formula
Method 1: Remove first or last x characters from text strings with formulas
Remove first x characters from the beginning of the text strings:
In Excel, you can use the RIGHT and LEFT functions to remove the certain number of characters from the beginning or the end of the strings, please do as this:
1. Type or copy the following formula in a blank cell C4 where you want to put the result:
and press Enter key to get the first result. See screenshot:
Note: In the above formula:
- A4 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.
2. Then, select the cell C4 and drag the fill handle down to the cells where you want to apply this formula, and all the first 2 characters have been removed from the text strings, see screenshot:
Remove last x characters from the end of the text strings:
If you need to remove the last several characters, you can use the LEFT function as the same as the RIGHT function.
Please enter or copy this formula into a blank cell:
and then drag the fill handle down to the cells that you want to apply this formula, and last 9 characters have been deleted from the text strings at once, see screenshot:
Note: In the above formula:
- A4 is the cell value that you want to remove characters;
- The number 9 means the number of characters you want to remove from the end of the text string.
Method 2: Remove first or last x characters from text strings with User Defined Function
Here is a User Defined Function which also can help you to remove first or last n characters from text strings, please do as this:
Remove first x characters from the beginning of the text strings:
1. Hold down the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
Public Function removeFirstx(rng As String, cnt As Long)
removeFirstx = Right(rng, Len(rng) - cnt)
End Function
3. Then go back to the worksheet, and then enter this formula: =removefirstx(A4,2) into a blank cell, and then drag the fill handle down to get the results as you need, see screenshot:
Note: In the above formula:
- A4 is the cell that you want to remove characters;
- The number 2 indicates the number of characters you would like to remove from the beginning of the text string.
Remove last x characters from the end of the text strings:
To remove last n characters from the text strings, please apply the following User Defined Function:
Public Function removeLastx(rng As String, cnt As Long)
removeLastx = Left(rng, Len(rng) - cnt)
End Function
And then apply this formula: =removelastx(A4,9) to get the results as you need, see screenshot:
Note: In the above formula:
- A4 is the cell that you want to remove characters;
- The number 9 indicates the number of characters you would like to remove from the end of the text string.
Method 3: Remove first, last x characters or certain position characters without any formulas
Using the Excel functions to remove certain characters is not as directly as it is. Just take a look at the way provided in this method, which is no more than two or three mouse clicks. With the Remove by Position utility of the third party add-in Kutools for Excel, you can be easy to remove first, last or certain characters from the text string. Click to download Kutools for Excel! Please see below demo:
After installing Kutools for Excel, please apply Remove by Position according to these steps:
1. Select the range that you want to remove the certain characters. Then click Kutools > Text > Remove by Position. See screenshot:
2. Specify the following operations in the pop-up Remove by Position dialog box.
- (1.) Specify the number of characters to be deleted.
- (2.) Choose From left option under the Position section to delete the first n characters, see screenshot:
Tips: The Remove by Position utility also can help you to remove the last n characters or the certain characters from specific position.
Method 4: Remove both first x and last x characters from text strings with formula
Sometimes, you would like to remove characters from text strings on both sides, for example, you need to remove first 2 characters and last 9 characters at the same time. Here, the MID function can do you a favor.
1. Please enter or copy this formula into a blank cell:
and press Enter key to get the first result. See screenshot:
Note: In the above formula:
- A4 is the cell value that you want to remove characters;
- The number 3 is one more than the number of characters you want to remove from the left side;
- The number 11 is the total number of characters you want to remove.
2. Then, select the cell C4 and drag the fill handle down to the cells where you want to apply this formula, and all the first 2 and last 9 characters have been removed immediately from the text strings, see screenshot:
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!