3 Ways To Remove Last 2 Characters In Excel

Intro

Learn how to remove last 2 characters in Excel with 3 easy methods. Discover formulas and functions to truncate text strings, including the RIGHT, LEN, and MID functions. Master Excel string manipulation and data cleaning techniques to streamline your workflow. Get the solution to remove unwanted characters from your Excel data.

3 Ways To Remove Last 2 Characters In Excel

remove last 2 characters excel

Removing the last 2 characters from a text string in Excel can be a daunting task, especially for those who are new to the software. Fortunately, there are several ways to accomplish this task, and in this article, we will explore three methods to remove the last 2 characters from a text string in Excel.

Method 1: Using the LEFT Function

The LEFT function is a popular choice for removing characters from the end of a text string. This function returns a specified number of characters from the start of a text string. To remove the last 2 characters from a text string, you can use the LEFT function in combination with the LEN function, which returns the length of a text string.

For example, if you want to remove the last 2 characters from the text string " ABCDEFG", you can use the following formula:

=LEFT(A1,LEN(A1)-2)

Assuming the text string is in cell A1, this formula will return " ABCDEF".

How to Use the LEFT Function

left function excel

Here's how to use the LEFT function:

  1. Select the cell where you want to display the result.
  2. Type "=LEFT(" and select the cell that contains the text string.
  3. Type ",LEN(" and select the cell that contains the text string again.
  4. Type ")-2)" to remove the last 2 characters.
  5. Press Enter to get the result.

Method 2: Using the MID Function

The MID function is another powerful function in Excel that can be used to remove characters from a text string. This function returns a specified number of characters from the middle of a text string.

To remove the last 2 characters from a text string, you can use the MID function in combination with the LEN function.

For example, if you want to remove the last 2 characters from the text string " ABCDEFG", you can use the following formula:

=MID(A1,1,LEN(A1)-2)

Assuming the text string is in cell A1, this formula will return " ABCDEF".

How to Use the MID Function

mid function excel

Here's how to use the MID function:

  1. Select the cell where you want to display the result.
  2. Type "=MID(" and select the cell that contains the text string.
  3. Type ",1," to start from the first character.
  4. Type "LEN(" and select the cell that contains the text string again.
  5. Type ")-2)" to remove the last 2 characters.
  6. Press Enter to get the result.

Method 3: Using VBA Macro

If you prefer to use VBA macros, you can create a custom function to remove the last 2 characters from a text string.

Here's an example code:

Function RemoveLast2Characters(text As String) As String
    RemoveLast2Characters = Left(text, Len(text) - 2)
End Function

To use this function, follow these steps:

  1. Press Alt + F11 to open the VBA editor.
  2. In the VBA editor, click Insert > Module to insert a new module.
  3. Paste the code into the module.
  4. Save the module by clicking File > Save.
  5. Go back to the Excel worksheet and select the cell where you want to display the result.
  6. Type "=RemoveLast2Characters(" and select the cell that contains the text string.
  7. Press Enter to get the result.

Gallery of Remove Last 2 Characters Excel

I hope this article has been helpful in teaching you how to remove the last 2 characters from a text string in Excel. If you have any questions or need further assistance, please don't hesitate to ask.

Jonny Richards

Love Minecraft, my world is there. At VALPO, you can save as a template and then reuse that template wherever you want.