MS-Excel / General Formatting

Recording Absolute Macro

Follow these steps to record a simple macro in absolute mode. This macro simply enters three month names into a worksheet:

  1. Choose Developer> Code> Record Macro.
  2. Type Absolute as the name for this macro.
  3. Click OK to begin recording.
  4. Activate cell B1 and type Jan in that cell.
  5. Move to cell C1 and type Feb.
  6. Move to cell D1 and type Mar.
  7. Click cell B1 to activate it again.
  8. Stop the macro recorder.
  9. Press Alt+F11 to activate the VBE.
  10. Examine the Module1 module.

Excel generates the following code:

Sub Absolute()
'
' Absolute Macro
' Macro recorded by Rodi Ken
'
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Jan"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Feb"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Mar"
    Range("B1").Select
End Sub

When executed, this macro selects cell B1 and inserts the three month names in the range B1:D1. Then the macro reactivates cell B1.

These same actions occur regardless of which cell is active when you execute the macro. A macro recorded by using absolute references always produces the same results when it is executed. In this case, the macro always enters the names of the first three months into the range B1:D1.

[Contents] [Next]

In this tutorial:

  1. Excel Relative or Absolute Macro
  2. Recording Absolute Macro
  3. Recording Relative Macro