#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 683
Default Macros

I am trying to create the simplest of macros. I just want to delete the first
4 characters of a cell, and then have it repeat that process for about 350
cells. Everytime I hit record and give it a name and hot key. I preform the
steps of deleting 4 characters in a cell and hit enter to goto the next cell.
I hit stop recording and then try to run the macro, which at this point does
not work.. Can ANYONE HELP. What am I doing wrong

Thanks
Brian


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 186
Default Macros

Hi Brian,
Assuming that you have data in column A and that the first cell is A1, the
following macro should do the job. It will do nothing if there are four or
fewer characters in a cell.

Option Explicit
Dim CountRows As Double
Dim Iloop As Double
Sub DeleteCharacters()

'Turn off warnings, etc.
Application.ScreenUpdating = False
Application.DisplayAlerts = False

CountRows = Cells(Rows.Count, "A").End(xlUp).Row
For Iloop = 1 To CountRows
If Len(Cells(Iloop, "A")) 4 Then
Cells(Iloop, "A") = Right(Cells(Iloop, "A"), _
Len(Cells(Iloop, "A")) - 4)
End If
Next Iloop

'Turn off warnings, etc.
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
--
Ken Hudson


"Brian" wrote:

I am trying to create the simplest of macros. I just want to delete the first
4 characters of a cell, and then have it repeat that process for about 350
cells. Everytime I hit record and give it a name and hot key. I preform the
steps of deleting 4 characters in a cell and hit enter to goto the next cell.
I hit stop recording and then try to run the macro, which at this point does
not work.. Can ANYONE HELP. What am I doing wrong

Thanks
Brian


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Macros

What are you doing wrong.........?

You cannot record or run a macro while in Edit mode which is the mode you are in
when deleting the first four characters.

See the macros from Don and Ken to get what you want.


Gord Dibben MS Excel MVP

On Tue, 18 Mar 2008 14:27:01 -0700, Brian
wrote:

I am trying to create the simplest of macros. I just want to delete the first
4 characters of a cell, and then have it repeat that process for about 350
cells. Everytime I hit record and give it a name and hot key. I preform the
steps of deleting 4 characters in a cell and hit enter to goto the next cell.
I hit stop recording and then try to run the macro, which at this point does
not work.. Can ANYONE HELP. What am I doing wrong

Thanks
Brian



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
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Macros [email protected] Charts and Charting in Excel 0 November 7th 07 08:53 PM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
"openinf file..."ENABLE MACROS...DISABLE MACROS" F. Lawrence Kulchar Excel Discussion (Misc queries) 3 September 12th 06 10:33 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


All times are GMT +1. The time now is 05:02 PM.

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"