Intro
Learn how to Excel remove last two characters from right using formulas and functions, including RIGHT, LEN, and SUBSTITUTE, to manipulate text strings and extract desired data.
Removing the last two characters from a string in Excel can be accomplished using several methods, including the use of formulas. The most straightforward approach involves using the LEFT function, which extracts a specified number of characters from the left side of a text string. Here's how you can do it:
Using the LEFT Function
The LEFT function's syntax is LEFT(text, [num_chars])
, where text
is the string from which you want to extract characters, and [num_chars]
is the number of characters you want to extract from the left. If you want to remove the last two characters from a string, you need to extract all characters except the last two. The formula to achieve this is:
=LEFT(A1, LEN(A1) - 2)
A1
is the cell containing the text from which you want to remove the last two characters.LEN(A1)
calculates the total length of the text in cell A1.LEN(A1) - 2
subtracts 2 from the total length, effectively giving you the length of the string minus the last two characters.LEFT(A1, LEN(A1) - 2)
then extracts that many characters from the left of the string, effectively removing the last two characters.
Example
Suppose you have the text "ExampleText" in cell A1, and you want to remove the last two characters ("xt") from it.
- Enter the formula
=LEFT(A1, LEN(A1) - 2)
in a new cell, say B1. - Press Enter.
- The result in B1 will be "ExampleTe", which is "ExampleText" with the last two characters removed.
Using VBA Macro
If you prefer using VBA or need to apply this operation to a large dataset repeatedly, you can create a simple macro. Here's how:
- Open Excel and go to the Visual Basic Editor (Press
Alt + F11
or navigate to Developer > Visual Basic). - In the Visual Basic Editor, insert a new module (Right-click on any of the objects for your workbook listed in the left-hand window > Insert > Module).
- Paste the following code into the module window:
Sub RemoveLastTwoChars()
Dim rng As Range
For Each rng In Selection
If Len(rng.Value) > 2 Then
rng.Value = Left(rng.Value, Len(rng.Value) - 2)
Else
rng.Value = ""
End If
Next rng
End Sub
- Save the module by clicking
File
>Save
(or pressCtrl + S
). - Go back to your Excel sheet, select the cells you want to apply the macro to.
- Press
Alt + F8
, selectRemoveLastTwoChars
, and clickRun
.
This macro will remove the last two characters from each selected cell. If a cell contains two or fewer characters, it will clear the cell.
Final Thoughts
Removing the last two characters from strings in Excel is a straightforward process, whether you're using formulas or VBA macros. The method you choose depends on your specific needs and preferences. For one-time or occasional use, the formula method is quick and easy. For repetitive tasks or when dealing with large datasets, a VBA macro can be more efficient.

Excel Functions for Text Manipulation
Excel offers a variety of functions for manipulating text, including LEFT, RIGHT, MID, LEN, and more. Understanding these functions can greatly enhance your ability to work with text data in Excel.

LEFT Function
The LEFT function extracts a specified number of characters from the left side of a text string.

RIGHT Function
The RIGHT function extracts a specified number of characters from the right side of a text string.

Practical Applications
Removing the last two characters from strings can have various practical applications, such as data cleaning, formatting names or codes, and preparing data for import into other systems.

Data Cleaning
Data cleaning is an essential step in data analysis. It involves removing or correcting invalid, incorrect, or irrelevant data to ensure the quality and reliability of the data.

Conclusion and Next Steps
In conclusion, removing the last two characters from strings in Excel is a useful skill that can be applied in various scenarios. By mastering the LEFT function and understanding how to use VBA macros, you can efficiently manipulate text data in Excel.

Further Learning
To further enhance your Excel skills, consider exploring more advanced topics such as pivot tables, Power Query, and macros.

Excel Text Manipulation Gallery










What is the purpose of the LEFT function in Excel?
+The LEFT function is used to extract a specified number of characters from the left side of a text string.
How do I remove the last two characters from a string in Excel?
+You can use the formula =LEFT(A1, LEN(A1) - 2) to remove the last two characters from a string in cell A1.
What is the difference between the LEFT and RIGHT functions in Excel?
+The LEFT function extracts characters from the left side of a string, while the RIGHT function extracts characters from the right side.
We hope this article has been informative and helpful in your journey to master Excel. Feel free to share your thoughts, ask questions, or explore more topics related to Excel and data analysis.