Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro that deletes the last character in a cell

I have an 18,000 record database and every entry is a name with the
letter A added to the end. for example: Lastname, firstname A
. I need a macro that will open the cell, backspace the "A" out of
there, close the cell for editing, moves down one record or line and
loops back to editing the cell and removing the A. This was simple in
Lotus but I'm not a programmer and I really don't want to spend 20
hours hitting, F2, Backspace, enter. Does anyone have a simple
solution. I do know how to set up a macro in Excel but that's about it.
Thanks ...TJ

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Macro that deletes the last character in a cell

How about this?
Sub TryThis()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If VarType(cell) = vbString Then
cell = Left(cell, Len(cell) - 1)
End If
Next cell
End Sub
James

TJ wrote:
I have an 18,000 record database and every entry is a name with the
letter A added to the end. for example: Lastname, firstname A
. I need a macro that will open the cell, backspace the "A" out of
there, close the cell for editing, moves down one record or line and
loops back to editing the cell and removing the A. This was simple in
Lotus but I'm not a programmer and I really don't want to spend 20
hours hitting, F2, Backspace, enter. Does anyone have a simple
solution. I do know how to set up a macro in Excel but that's about it.
Thanks ...TJ


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Macro that deletes the last character in a cell

TJ

The following assumes records start at row 2 (allowing header in row 1)
and that the names with the A on the end are in column A.

Sub Test()
For Each c in Range("A2:A" & Range("A65536").End(xlUp).Row)
c.Value = Left$(c.Value,Len(c.Value)-1)
Next c
End Sub

Stick this in a standard module in the workbook containing the data
(Alt+F11 to get the VBE open, right click on the workbook name in the
Projects pane (top left) and go InsertModule and post the code in the
big white space that opens). Back in the spreadsheet, on the sheet
with the records, go ToolsMacroMacros and select Test from the list
and click Run.

Hope this helps!

Richard


TJ wrote:
I have an 18,000 record database and every entry is a name with the
letter A added to the end. for example: Lastname, firstname A
. I need a macro that will open the cell, backspace the "A" out of
there, close the cell for editing, moves down one record or line and
loops back to editing the cell and removing the A. This was simple in
Lotus but I'm not a programmer and I really don't want to spend 20
hours hitting, F2, Backspace, enter. Does anyone have a simple
solution. I do know how to set up a macro in Excel but that's about it.
Thanks ...TJ


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Macro that deletes the last character in a cell

Richard, would you be so kind as to explain your use of the $ character
in the term Left$. It appears to be a typecasting character from my
old BASIC days. What are the implications of using the $ character
with Left at run-time? TIA, James

c.Value = Left$(c.Value,Len(c.Value)-1)

RichardSchollar wrote:
TJ

The following assumes records start at row 2 (allowing header in row 1)
and that the names with the A on the end are in column A.

Sub Test()
For Each c in Range("A2:A" & Range("A65536").End(xlUp).Row)
c.Value = Left$(c.Value,Len(c.Value)-1)
Next c
End Sub

Stick this in a standard module in the workbook containing the data
(Alt+F11 to get the VBE open, right click on the workbook name in the
Projects pane (top left) and go InsertModule and post the code in the
big white space that opens). Back in the spreadsheet, on the sheet
with the records, go ToolsMacroMacros and select Test from the list
and click Run.

Hope this helps!

Richard


TJ wrote:
I have an 18,000 record database and every entry is a name with the
letter A added to the end. for example: Lastname, firstname A
. I need a macro that will open the cell, backspace the "A" out of
there, close the cell for editing, moves down one record or line and
loops back to editing the cell and removing the A. This was simple in
Lotus but I'm not a programmer and I really don't want to spend 20
hours hitting, F2, Backspace, enter. Does anyone have a simple
solution. I do know how to set up a macro in Excel but that's about it.
Thanks ...TJ


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro deletes row in range, macro then skips the row moved up steven.holloway Excel Discussion (Misc queries) 8 June 11th 08 11:40 AM
Macro that deletes rows from cell containing End to end of data. Richard Excel Discussion (Misc queries) 2 July 25th 07 03:51 PM
Macro that deletes every third row....+ ajjag Excel Discussion (Misc queries) 4 June 27th 06 06:03 PM
Macro that deletes certain rows and not others Roger[_20_] Excel Programming 8 May 3rd 05 12:02 AM
hitting spacebar in excel deletes last character entered. badgercat New Users to Excel 0 March 14th 05 09:47 PM


All times are GMT +1. The time now is 04:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"