Macros

Advanced
20 min

What is Macros?

Macros automate repetitive tasks in Excel using VBA (Visual Basic for Applications), saving time and reducing errors.

Key Components:

  • Records your actions to replay later
  • Automates repetitive tasks
  • Can be edited for complex automation
  • Saves hours of manual work

Why it matters

Automate Reports

Generate daily reports automatically

Save Time

Eliminate repetitive work

Reduce Errors

Consistent execution every time

Standardize Outputs

Create uniform reports

Key Concepts

Record Macro

Record actions for playback

Example: Formatting steps...

Run Macro

Execute recorded macro

Example: Play back formatting...

VBA Editor

Edit macro code

Example: Visual Basic editor...

Button

Assign macro to button

Example: Click to run...

How to use

1

Enable Developer tab

File → Options → Customize Ribbon → Check Developer

2

Record Macro

Developer → Record Macro

3

Name macro

Give it a descriptive name

4

Perform actions

Do the tasks you want to automate

5

Stop Recording

Click Stop Recording

6

Run Macro

Developer → Macros → Run

Example

Goal: Automate report formatting
Record Macro → Apply formatting (bold headers, borders, colors) → Stop → Save
Result: One-click formatting for any report

Pro Tips

  • Save as .xlsm: Enable macro storage
  • Use relative references: Flexible macro
  • Test on backup: Avoid data loss

Practice

Record a macro that formats a sales report with bold headers and currency