This tutorial demonstrates different quick tricks to remove first or last N characters from a cell or a string in Excel. In this part, I introduce three different ways to quickly remove first N characters from a string. 1.1 Remove first N characters with RIGHT / REPLACE function>> Combine RIGHT and LEN function to remove first N characters
Formula syntax and arguments Formula: =RIGHT(string_cell,LEN(string_cell)-n_character) Reference: string_cell: the cell you use to remove characters n_character: the number of characters you want to remove Example: Remove first 2 characters from string in Cell A2, copy and paste the formula >> REPLACE function to remove first N characters
Formula syntax and arguments Formula: =REPLACE(Old_text,Strat_n,Num_Chars,New_text) Reference: Old_text: the cell you use to replace characters Old_text: the cell you use to replace characters Start_n: the position of the character in old_text that you want to replace with new_text Num_Chars: the number of characters in old text that you want to replace with new_text New_text: the text that will replace the old_text Example: Replace first two characters with nothing in Cell A6, copy and paste this formula: 1.2 Remove first N characters with user defined function1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window, then click Insert > Module to create a Module. 2. Copy below code and paste them to the Module script. VBA Code: Remove first n characters Public Function RemoveFirstC(rng As String, cnt As Long) RemoveFirstC = Right(rng, Len(rng) - cnt) End Function3. Save the code and go back to the sheet you use. For example, remove first 3 characters from string in Cell A11, copy and paste this formula
In this part, there are two ways for removing last N characters from string in Excel. 2.1 Remove last N characters with LEFT function
Formula syntax and arguments Formula: =LEFT(string_cell,LEN(string_cell)-Num_chars) Reference: string_cell: the cell you use to remove characters n_character: the number of characters you want to remove Example: Remove last 2 characters from string in Cell A2, copy and paste the formula 2.2 Remove last N characters with user defined function1. Press Alt + F11 keys to enable Microsoft Visual Basic for Applications window, click Insert > Module to create a Module. 2. Copy below code and paste them to the Module script. VBA Code: Remove last n characters Public Function RemoveLastC(rng As String, cnt As Long) RemoveLastC = Left(rng, Len(rng) - cnt) End Function3. Save the code and go back to the sheet you use. For example, remove last 3 characters from string in Cell A5, type this formula
If you do not want to waste time to remember formulas to deal with the task on removing N characters from left or right of a string, the Remove by Position utility of Kutools for Excel can handle this task with clicks without any formulas.
Now, Make You Work Faster And Better Than Others, Get Promotion With Ease
35 Text Editing Tools For Excel Improve Your 90% Productivity In Text Processing And Leave Much Time To Enjoy Life These tools just one part of Kutools for Excel, there are 194 tools else can solve 80% Excel puzzles for you.
After free installing Kutools for Excel, please do as below: Select the cells you want to remove characters from, applying the utility by clicking Kutools > Text > Remove by Position. 3.1 Remove first/last N characters without formula>> Remove first N characters
Result is displayed as: >> Remove last N characters
Result is displayed as: 3.2 Remove N characters from a middle specific position without formulaBut in sometimes, you may want to remove a specific number of characters from the middle of a string. Example: Remove 3 characters starts from the third characters from the string.
Result is displayed as:
Full-featured free trial ( 30-day) Tip: If you want to remove all numeric, alpha, non-numeric, non-alpha or specific characters from cells, you can apply Kutools for Excel's Remove Characters utility. More tips on removing characters...
Full- featured free trial in 30 days Full- featured free trial in 30 days |