Link to home
Start Free TrialLog in
Avatar of rdefino
rdefinoFlag for United States of America

asked on

Need to remove last 3 characters in each excel cell

I have a column that's has about 200 cells in it and I need to remove the last 3 characters from each cell.

 i found this:

For Each cell In Selection
cell.Value = LEFT(cell,LEN(cell)-3)
Next cell


But I have no idea how to run it against the column.

any thoughts.
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Place this code in a general code module:

Public Sub TrimCells()
Dim Cell As Range
For Each Cell In Selection
Cell.Value = LEFT(Cell,LEN(Cell)-3)
Next Cell
End Sub

Select the cells to edit and run the macro.

Kevin
In Excel - highlight a selection

1) go to the VBA IDE with Alt+F11
2) Create a module - Insert - Module
3) Create a Procedure - Insert - Procedure - "CutLast3Chars"
4) paste the code between Public sub ... and End Sub
5) while the cursor is also between the Pub sub and End sub, press F5

The module will be saved with this spreadsheet only

from then on - from the spread sheet - you can:
1) make a selection,
2) press Alt+F8
3) Click on CutLast3Chars and click on Run

Hope this helps.
ASKER CERTIFIED SOLUTION
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rdefino

ASKER

Very easy, thanks!