Recording Macros

Recording a Macro allows you to capture your actions in Excel and save them as VBA code. Once recorded, you can run the macro anytime to repeat those actions automatically.

It is one of the easiest ways to start learning VBA without writing code manually.

What is a Macro?

A Macro is a set of recorded steps that Excel converts into VBA (Visual Basic for Applications) code.

Example:
If you apply formatting daily (bold headers, change font, apply borders), you can record it once and reuse it anytime.

Why Record Macros?

  • Automate repetitive tasks
  • Save time
  • Reduce manual errors
  • Create quick formatting tools
  • Generate automated reports

Enable Developer Tab (If Not Visible)

  1. Go to File → Options
  2. Click Customize Ribbon
  3. Check Developer
  4. Click OK

Steps to Record a Macro

  1. Go to Developer Tab
  2. Click Record Macro
  3. Enter:
    • Macro Name (no spaces, e.g., FormatReport)
    • Shortcut Key (optional)
    • Store Macro In:
      • This Workbook
      • New Workbook
      • Personal Macro Workbook
  4. Click OK
  5. Perform the actions you want to record
  6. Click Stop Recording

Your macro is now saved.

Running a Macro

Method 1:

Developer → Macros → Select Macro → Run

Method 2:

Use the assigned shortcut key

Method 3:

Assign macro to a button

View Recorded VBA Code

  1. Developer → Visual Basic
  2. Open Modules
  3. View your recorded code

Example recorded code:

Sub FormatReport()
Range("A1:D1").Font.Bold = True
Columns("A:D").AutoFit
End Sub

Where to Store Macros

  • This Workbook → Only works in current file
  • Personal Macro Workbook → Available in all Excel files

Important Notes

  • Save file as .xlsm (Macro-Enabled Workbook)
  • Macros cannot undo actions
  • Avoid unnecessary clicks while recording
  • Use relative references if needed

Relative vs Absolute Reference

Absolute Reference:

Records exact cell (A1 always A1)

Relative Reference:

Records movement from active cell

Enable from:
Developer → Use Relative References

Best Practices

  • Plan steps before recording
  • Keep macros simple
  • Give meaningful names
  • Test macro after recording
  • Edit code to improve efficiency

Benefits of Recording Macros

  • Beginner-friendly
  • No coding required
  • Quick automation
  • Improves productivity
  • Introduction to VBA

Conclusion

Recording Macros is the easiest way to automate tasks in Excel. It allows users to convert repetitive manual work into automatic processes, making workflow faster and more efficient.

Home » Excel Automation & Power Tools (EAPT) > Introduction to Macros > Recording Macros