Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need to remove last 3 characters in each excel cell

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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