Remove characters from right

Learn how to remove characters from the right of the text using various Excel functions. Discover how to remove the last n characters from a text string.

If you have a data cleaning task, in some cases, we have to keep only the specific parts of a text or string.

You can save your time if you have a versatile Excel toolbox with custom functions. In this article, we will explain the most used formula examples and functions syntaxes.

Generic Formula to Remove Characters from Right

=LEFT(text,LEN(text)-n)

Arguments of the LEFT function:

  • text: the text from which you want to remove the last n characters in excel
  • numbers_of_characters: the numbers of characters we want to remove.

The argument of the LEN function:

  • text: the cell which contains text

Let us examine the formula above! We have some functions to strip characters from the right. But we want to find a solution to make sure everyone clearly understands. So, we’ll apply an inverse formula and try to extract the characters from left.

What should we do? Calculate the result using the following logic:

=(Count the length of the full string) – (N characters from right to left)

How this formula works

LEFT and LEN formula to strip text

As first, we extract the given number (n characters) from the left of the text.

=LEN(A2)-2 = 6

Now we know the proper length of the string. It’s time to execute the second part of the formula. We will use the result as a parameter of the LEFT formula. To remove the last n characters, use a combination of a LEFT and LEN functions.

=LEFT(LEN(A2)-2) 
=LEFT(6) = Example

TEXTLEFT function to remove characters from right

The TEXTLEFT function did not exist in Excel by default. Fortunately, we have implemented a huge custom function library into our free Excel add-in.

We’ll show you an example to demonstrate the power of the user-defined functions.

TEXTLEFT function to remove characters from right

Type the formula:

=TextLEFT(A3,"@")

So the unnecessary part of the text will be removed. TEXTLEFT is one of the effective function if you are working with delimiters or wildcards in Excel.

Extract values from right using VALUE

Let’s the next example! We want to extract 855 from cell A5. LEN calculates the total length of the string is in A6. The result is 9.

If you evaluate the

=LEFT(A5,LEN(A5)-6))

expression, it will return the text ”855”. It’s a text value! We have to convert the text value to number format.

Extract values from right using VALUE

Apply the below formula for the proper result:

=VALUE(LEFT(A5,(LEN(A5)-6)))

Remove the last nth characters using VBA

Because we are familiar with VBA programming, we are working on our main goal: to write better and better time-saving formulas for the Excel community.

Check this example below; it is easy to see how the formula built.

Function RemoveLastNchar(rng As String, counter As Long)
RemoveLastNchar = LEFT(rng, LEN(rng) - counter)
End Function
Remove the last nth characters using VBA

Delete the last nth characters from right using an add-in

Use our DataXL productivity tools for Excel and follow these steps below:

  1. Locate the DataXL tab on the ribbon. Select the cell which contains the text.
  2. Click on the Text Tools icon. A new window will appear. Select the second tab, Delete.
  3. Enter the value.
  4. Example: If you want to remove the last six characters from right, use 6 as a parameter.
Delete the last nth characters from right using an add-in

Additional resources and formula examples