Macros Introduction
Record and run Excel Macros to automate repetitive tasks without writing code.
✅ What You Will Learn
A Macro is a recorded sequence of actions in Excel. You press Record, perform a series of steps — formatting, filtering, copying data — and Excel translates every action into code. When you run the Macro, Excel executes all those steps automatically in seconds, no matter how many rows of data are involved.
Macros are stored as VBA (Visual Basic for Applications) code behind the scenes. You do not need to know VBA to record and use basic Macros — the recorder generates the code for you. However, understanding a little VBA lets you edit recorded Macros to make them smarter and more flexible.
Macro-enabled files are saved as .xlsm (not .xlsx). When you open a .xlsm file, Excel shows a security warning asking you to enable Macros — always verify the file source before clicking Enable.
Examples
📌 Key Points to Remember
- ✓Save the file as .xlsm (Macro-Enabled Workbook) or all Macros are lost when closing
- ✓Macro names cannot have spaces — use CamelCase or underscores: FormatReport or Format_Report
- ✓Use Relative Recording when the Macro should work from any starting cell, not always from A1
- ✓Developer tab → Visual Basic opens the VBA Editor where you can view and edit recorded code
- ✓Never enable Macros in files received from unknown sources — Macros can contain malicious code
🏢 Real-World Application
Reporting analysts at banks and BPOs use Macros to automate end-of-day report generation. A single button click formats the raw data export, applies conditional formatting, generates a summary table, adds the date header, and saves a copy to a shared folder — 40 steps completed in 3 seconds. What used to take 20 minutes of manual work per day is reduced to a single button press.
⚠️ Common Mistakes to Avoid
❓ Frequently Asked Questions
Do I need to know programming to use Macros?
No — the Macro Recorder generates VBA code for you automatically. For basic automation (formatting, filtering, copying) the recorder is enough. VBA knowledge lets you edit the recorded code to handle dynamic data and add logic.
Can I run a Macro automatically when a file opens?
Yes — create a Sub named Auto_Open() or a Workbook_Open() event in the ThisWorkbook module. This Macro runs automatically every time the file is opened.
Are Macros compatible across Excel versions?
Generally yes — VBA Macros written in Excel 2016 run in Excel 2019 and Microsoft 365. There are occasional differences with newer features. Macros are not supported in Excel Online.
✏️ Practice Exercise
Record a Macro that: (1) Selects the active sheet data range, (2) Applies alternating row colours (light grey every other row), (3) Makes the header row bold with a dark background and white text, (4) Auto-fits all column widths, (5) Saves the file. Assign it to a button labelled "Format Report". Test it on a different dataset on a new sheet.
Learn Excel with Live Trainer Guidance
These tutorials give you the foundations. Our live Excel course at EVIKA Academy, Noida teaches you to build real dashboards on actual business data — with a trainer who uses Excel professionally every day.