Theory
The same twenty clicks, every month
Every month Aryan builds Meera's report the same way: import, format the header, sort by sales, add totals, colour the low-stock rows. Twenty-plus clicks, identical every time, twenty minutes of tedium.
Computers exist to do exactly this: repeat a task without complaint (remember BCA103's 'diligence'?). So why is Aryan doing it by hand?
A macro records his actions once and replays them on command. Next month, one button press does all twenty steps. And the best part: Excel writes the code for him as he records. This is where you stop using Excel and start automating it.
Theory
A player piano roll
An old player piano records a pianist's performance onto a roll, then plays it back exactly, key for key, whenever you want, no pianist needed. A macro is that roll for Excel: perform your actions once while it 'records', and it captures every step. Press play (run the macro) and Excel re-performs the whole sequence perfectly. You taught it once; it repeats forever.
Follow along
Record and run your first macro
- Developer tab > Record Macro; name it and set a shortcut Recording starts now, every action is captured.
- Perform the task once: format, sort, add totals Do it exactly as you want it replayed.
- Click Stop Recording Excel has written the VBA code for your steps automatically.
- Run it next month: press the shortcut or the Macros button All the steps replay in one go. Save as .xlsm to keep the macro.
Quiz
Aryan records a great macro, then saves the workbook as a normal .xlsx and closes it. Next month the macro is gone. Why?
- Macros require the macro-enabled .xlsm format; .xlsx silently strips them
- Macros expire after a month
- He recorded it wrong
- Macros only work while Excel stays open
Show the answer
Macros require the macro-enabled .xlsm format; .xlsx silently strips them
A plain .xlsx cannot store macros, so saving in that format strips the macro (often with a warning that is easy to miss). Macro-containing workbooks must be saved as .xlsm (macro-enabled). This is the exact trap flagged back in the saving lesson: match the format to what the file holds. Losing a macro to a .xlsx save is a classic real-world (and exam) mistake.
Think first
Why the security warnings?
When Aryan opens a workbook from an unknown source, Excel warns 'Macros have been disabled' and asks whether to enable content. Why is Excel so cautious about macros specifically?
Show the answer
Because a macro is real code that can do powerful (and harmful) things, delete files, alter data, spread to other workbooks. A malicious macro in a file from an untrusted source could damage your system, so Excel disables macros by default and asks before running them. Enable content only from sources you trust. This is why macro-enabled files are treated as a security consideration, the same code-can-be-dangerous logic as any downloaded program (BCA103).
Watch out
Where marks leak
Forgetting macros need .xlsm (macro-enabled) to survive saving. Not knowing macros are recorded via the Developer tab / Record Macro and replay captured actions. Missing the security angle (untrusted macros can be malicious, hence the enable-content warning). And not realising Excel writes VBA code behind the scenes as you record, which is exactly what the next lesson opens up. Automation + security + .xlsm are the exam points.
Theory
Recorded code is your teacher
Here is the clever part: record a macro, then look at the code Excel wrote, it is VBA, a real programming language, and reading it is the easiest way to learn VBA. The recorder is your personal tutor. Next lesson opens the VBA editor and shows you the code behind your macro, connecting your BCA104 programming skills to Excel automation. Next: introduction to the VBA editor and basic VBA.
Summary
Key takeaways
- A macro records a sequence of actions once and replays them on command, automating repetitive tasks.
- Record via the Developer tab (Record Macro), perform the steps, Stop; run via shortcut or button.
- Excel writes VBA code capturing your actions as you record.
- Save as .xlsm (macro-enabled) or the macro is stripped on save.
- Macros are code and can be harmful, so Excel disables untrusted macros (enable content only from trusted sources).
- Memory hook: a player piano roll, record once, replay perfectly.