Recording VBA Macro and Fixing

Home page:
[View without Frames]

Excel does not record keystrokes.  What is produced
when you record a macro is VBA code.  VBA is a
programming lanuage.  Only the things that make a
difference are recorded.   Though I suppose that is
debatable since only one thing is recorded at a time
so there is a lot of garbage and redundant code.

If you want help with the generated code,  You should
post what was generated and what you want.  The
smaller you make what is to be looked at the better.

The following for instance would  place the previous
day's date into the current (activecell) and move down.
It will not affect the selection until the active cell moves
out of the selection range.
i.e.  try selecting  G9:H11 and then repeatedly run
this macro until you end up in G12.

Sub previousday()
   ActiveCell.Value = Int(Now) - 1
   ActiveCell.Offset(1, 0).Activate
End Sub

A recorded macro might look like this
for the current date.   I don't imagine that recording
a macro would have been a lot of help unless you
did not know about  activecell.    I would think of
recording a macro as just being a tool to help you
find something and then look it help in the VBE
Help.   (Help done from the VBA editor not the

Sub Macro4()
    ActiveCell.FormulaR1C1 = "8/24/2000"
End Sub
The STOP Recording dialog screen also has the Relative References.  If this box was closed during the recording of a macro you will no longer have a choice.  To get the toolbar back in sync with recording, start the macro recorder, use View|Toolbars and select the "Stop Recording" toolbar. Then stop the recorder.


You are one of many distinguished visitors who have visited my site here or in a previous location  since this page was created on August 24, 2000.

Visit [my Excel home page]   [Index page]   [Excel Onsite Search]   [top of this page]

Please send your comments concerning this web page to: David McRitchie send email comments

Copyright © 1997 - 2004,  F. David McRitchie,  All Rights Reserved