Intro
Learn how to Excel remove last two characters using formulas and functions, including RIGHT, LEFT, and LEN, to manipulate strings and text data efficiently.
Removing the last two characters from a string in Excel can be accomplished using several methods, including formulas and VBA scripts. Here's a comprehensive overview of how to achieve this:
The importance of manipulating text strings in Excel cannot be overstated, especially when dealing with data that requires cleaning or formatting before analysis. One common task is removing the last two characters from a string, which can be necessary for a variety of reasons, such as correcting data entry mistakes or conforming to specific formatting requirements.
Text manipulation in Excel is facilitated through various functions, including LEFT, RIGHT, LEN, and MID, among others. Understanding how to use these functions is crucial for efficiently managing and analyzing data in Excel. The LEFT and RIGHT functions are particularly useful for extracting parts of a string, while the LEN function is used to determine the length of a string, which is essential for calculating the position from which to start extracting or removing characters.
Using Formulas to Remove Last Two Characters

To remove the last two characters from a string in Excel using a formula, you can utilize the LEFT function in combination with the LEN function. The formula to achieve this is:
=LEFT(A1, LEN(A1) - 2)
This formula assumes the string from which you want to remove the last two characters is located in cell A1. Here's how it works:
LEN(A1)
calculates the total length of the string in cell A1.LEN(A1) - 2
subtracts 2 from the length, effectively determining the position up to which the string should be kept.LEFT(A1, LEN(A1) - 2)
then extracts the string from the beginning up to the calculated position, effectively removing the last two characters.
Applying the Formula
To apply this formula, follow these steps:- Select the cell where you want to display the result.
- Type the formula
=LEFT(A1, LEN(A1) - 2)
, assuming the original string is in cell A1. - Press Enter to execute the formula.
Using VBA to Remove Last Two Characters

For those comfortable with Visual Basic for Applications (VBA), you can create a custom function or macro to remove the last two characters from a string. Here's a simple VBA function that accomplishes this:
Function RemoveLastTwoCharacters(inputString As String) As String
If Len(inputString) > 2 Then
RemoveLastTwoCharacters = Left(inputString, Len(inputString) - 2)
Else
RemoveLastTwoCharacters = ""
End If
End Function
To use this VBA function:
- Open the Visual Basic Editor (VBE) by pressing
Alt + F11
or navigating to Developer > Visual Basic in the ribbon. - In the VBE, insert a new module by right-clicking on any of the objects for your workbook in the Project Explorer, then choose
Insert
>Module
. - Copy and paste the VBA function into the module.
- Save the workbook as a macro-enabled file (
.xlsm
).
Calling the VBA Function
To call this function in a worksheet, follow these steps:- Select the cell where you want to display the result.
- Type
=RemoveLastTwoCharacters(A1)
, assuming the original string is in cell A1. - Press Enter to execute the function.
Practical Applications and Examples

Removing the last two characters from strings can be useful in various scenarios, such as:
- Data Cleaning: When importing data from external sources, it's common to encounter formatting issues, such as trailing characters that need to be removed for the data to be usable.
- Text Formatting: In reports or presentations, you might need to remove suffixes or prefixes from product names, codes, or descriptions to conform to a specific format.
For example, if you have a list of product codes with a suffix "-AB" that you want to remove, you can use the formula =LEFT(A1, LEN(A1) - 3)
to remove the last three characters, assuming the code is in cell A1.
Gallery of Text Manipulation Examples
Text Manipulation Image Gallery










Frequently Asked Questions
How do I remove the first character from a string in Excel?
+You can use the RIGHT function in combination with the LEN function, like this: `=RIGHT(A1, LEN(A1) - 1)`, assuming the string is in cell A1.
Can I use VBA to automate text manipulation tasks in Excel?
+Yes, VBA is very powerful for automating tasks in Excel, including complex text manipulation. You can create custom functions or macros to perform specific tasks.
How do I extract a substring from a string in Excel?
+You can use the MID function to extract a substring. The syntax is `=MID(text, start_num, num_chars)`, where `text` is the string, `start_num` is the position to start extracting from, and `num_chars` is the number of characters to extract.
In conclusion, removing the last two characters from a string in Excel is a straightforward process that can be achieved through simple formulas or more complex VBA scripts, depending on your needs and preferences. Understanding how to manipulate text in Excel is a valuable skill that can greatly enhance your productivity and data analysis capabilities. Whether you're working with small datasets or large, complex spreadsheets, mastering text manipulation functions and techniques can help you achieve your goals more efficiently. So, take a moment to practice these methods, and soon you'll be effortlessly cleaning, formatting, and analyzing your data like a pro. Don't hesitate to reach out or share your own tips and tricks for working with text in Excel.