Click here for Introduction Click here for Table of Contents Click here for Examples and Special Topics
BarEnd.jpg (765 bytes)

  Recording and using macros

Think of a macro as a tape recorder for keystrokes. 
  • You can use Tools | Macro | Record to turn the recorder on and track whatever it is you do within Excel onscreen.  Remember to turn the recorder off when you are done...
  • Use Tools | Macro | Macros | Run to replay what you recorded.
  • You can use the Relative Reference button on the Macro toolbar to play back your macro relative to the current cursor position.  Otherwise, the macro will play in the same cells which you used when you recorded it.

When you record a macro, you will see the Stop Recording toolbar:

wpeB8.jpg (14299 bytes)

If you want more detail, here is the description from the Excel Help file.

Record a macro

  1. On the Tools menu, point to Macro, and then click Record.
  2. In the Macro name box, enter a name for the macro. 

    The first character of the macro name must be a letter. Other characters can be letters, numbers, or underscore characters. Spaces are not allowed in a macro name; an underscore character works well as a word separator.
  3. To run the macro by pressing a keyboard shortcut key, enter a letter in the Shortcut key box. You can use CTRL+ letter (for lowercase letters) or CTRL+SHIFT+ letter (for uppercase letters), where letter is any letter key on the keyboard. The shortcut key letter you use cannot be a number or special character. The shortcut key will override any default Microsoft Excel shortcut keys while the workbook that contains the macro is open.
  4. In the Store macro in box, click the location where you want to store the macro.

    If you want a macro to be available whenever you use Microsoft Excel, store the macro in the Personal Macro Workbook in the XLStart folder.

    To include a description of the macro, type the description in the Description box.
  5. Click OK.

    If you select cells while running a macro, the macro will select the same cells regardless of which cell is first selected because it records absolute cell references. If you want a macro to select cells regardless of the position of the active cell when you run the macro, set the macro recorder to record relative cell references. On the Stop Recording toolbar, click Relative Reference wpeB6.jpg (950 bytes). Microsoft Excel will continue to record macros with relative references until you quit Microsoft Excel or until you click Relative Reference macro_relative_reference.jpg (950 bytes) again.
  6. Carry out the actions you want to record.
  7. On the Stop Recording toolbar, click Stop Recording wpeB7.jpg (755 bytes).

    Tip If you want a macro to select a specific cell, perform an action, and then select another cell relative to the active cell, you can mix the use of relative and absolute references when you record the macro. To record a macro by using relative references, make sure that Relative Reference macro_relative_reference.jpg (950 bytes) is pressed in. To record with absolute references, make sure Relative Reference macro_relative_reference.jpg (950 bytes) is not pressed in.
Learn more

avi_icon.gif (229 bytes)

This video demonstrates recording and using a macro.