Solved

Need to remove last 3 characters in each excel cell

Posted on 2011-09-07
4
255 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

773 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