What a Macro Actually Is
A macro is a recorded (or written) set of instructions Excel replays on demand — formatting a report, cleaning imports, emailing summaries. VBA (Visual Basic for Applications) is the language behind them. You don't need to "learn programming" first: record, then read, then tweak.
Step 1 — Record Your First Macro (5 Minutes)
- Developer tab → Record Macro (enable Developer via File → Options → Customize Ribbon if hidden). Name it
FormatReport, store in This Workbook. - Perform the task once, deliberately: apply title formatting, autofit columns, add filters, freeze panes.
- Developer → Stop Recording. Press
Alt+F8, select it, Run — watch Excel replay you.
Step 2 — Read the Code (It's Friendlier Than You Think)
Press Alt+F11 → find Module1. Recorded code reads like English:
Sub FormatReport()
Range("A1").Font.Bold = True
Columns("A:F").AutoFit
Rows("1:1").FreezePanes ' conceptually — see fix below
End Sub
Delete the junk lines (.Select / Selection. pairs) — selecting cells is slow and fragile. Work on ranges directly.
Step 3 — Three Upgrades That Make It Assignment-Grade
Loop through every sheet
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Columns("A:F").AutoFit
Next ws
Ask before overwriting
If MsgBox("Format all sheets?", vbYesNo) <> vbYes Then Exit Sub
Fail gracefully
On Error GoTo CleanUp
Application.ScreenUpdating = False
' ... your code ...
CleanUp:
Application.ScreenUpdating = True
If Err.Number <> 0 Then MsgBox "Error: " & Err.Description
Save, Security & Submission Notes
- Save as .xlsm (macro-enabled) — .xlsx silently strips your code.
- Macros trigger security warnings: tell your professor to click Enable Content, and note it in your submission.
- Add a button (Developer → Insert → Button) linked to the macro so anyone can run it.
- Comment every block: what it does and why. Commented VBA consistently scores higher than clever uncommented VBA.
Automation project looming? We write documented, error-handled VBA — recorded where possible, hand-built where it counts — with a run guide.



