Solved

Need to remove last 3 characters in each excel cell

Posted on 2011-09-07
4
252 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:rdefino
4 Comments
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
ID: 36497687
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
0
 
LVL 5

Expert Comment

by:slycoder
ID: 36497716
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.
0
 
LVL 32

Accepted Solution

by:
Rob Henson earned 125 total points
ID: 36501208
In a blank column alongside the data put formula:

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

Assuming text in A1, amend accordingly.

Copy down the 200 rows and then copy paste special values back over the original text. Delete formulas if so required.

Thanks
Rob H
0
 

Author Closing Comment

by:rdefino
ID: 36536613
Very easy, thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now