Skip to main content

June 23th, 2026

What Is a Macro in Excel? How to Create One + Examples

By Drew Hahn · 14 min read

Learn about the 10 best AI HR Tools to use in 2025 - like Julius AI

Excel macros can save significant time on repetitive tasks, and for many common workflows, you don't need to know how to code to build one. I tested several approaches to find what works, so here's a practical breakdown of what an Excel macro is, how to create one, and when it's worth building.

What is a macro in Excel?

A macro in Excel is a saved set of steps that Excel replays on command. You record your actions once, and the next time you need to run that same process, Excel handles it automatically.

You don't always need to write code to create one. Excel's built-in macro recorder captures everything you do, from formatting cells to sorting data, and saves it as a reusable workflow.

What can Excel macros do? Common use cases and examples

Macros work best for tasks you repeat on a set schedule, where the steps are the same every time. Here are the most common ways people use them:

  • Formatting reports: If you manage multiple sheets of monthly sales data, a macro can apply the same header style, column widths, and borders across all of them at once, so you don't need to spend time copying styles from sheet to sheet. I use this one often for client reporting.

  • Cleaning up data: Exported data can come in messy, with extra spaces, inconsistent capitalization, or duplicate rows. A macro can trim whitespace, remove duplicates, and fix casing across thousands of rows without you touching each one manually.

  • Running weekly reports: This is the most common use case I see for business teams. If you pull the same report every Monday, a macro can handle the pivot table, sort the data, add a totals row, and set the print area automatically.

  • Applying formulas across large datasets: If you need to run the same calculation across hundreds of rows, a macro can apply that formula in one step instead of dragging it down manually.

  • Sending emails from Excel: If you use Outlook, a macro can pull data from your spreadsheet and send emails to a list of contacts. I've seen teams use this for invoice reminders and weekly updates without leaving Excel.

How to record a macro (no-code method)

Recording a macro doesn't require any coding knowledge. Excel watches what you do and saves it as a reusable workflow. 

Here's how to do it on both Windows and Mac:

Step 1: Enable the Developer tab

The Developer tab isn't visible by default. 

On Windows, go to File > Options > Customize Ribbon, check the Developer box, and click OK. 

On Mac, go to Excel > Preferences > Ribbon and Toolbar, and check the Developer box. 

You'll only need to do this once, and I'd recommend doing it before anything else.

Step 2: Click "Record Macro"

On Windows, open the Developer tab and click Record Macro. 

On Mac, go to the Developer tab and click Record Macro. 

A dialog box will appear asking you to name your macro, assign an optional keyboard shortcut, and choose where to store it. Select This Workbook to keep it tied to your current file.

Step 3: Perform your actions

Everything you do from this point is recorded. Walk through the task exactly as you normally would, whether that's formatting a header row, sorting a column, or applying a formula. Excel records your actions, not your speed, so take your time. I find it helps to do a dry run first so you don't record any mistakes.

Step 4: Stop recording

On Windows, click Stop Recording in the Developer tab. 

On Mac, click Stop Recording on the Developer tab. 

Your macro is now saved.

Step 5: Run your macro

On Windows, go to Developer > Macros, select your macro from the list, and click Run. 

On Mac, go to the Developer tab, click Macros, then select your macro and run it. 

If you assigned a keyboard shortcut in Step 2, you can use that on either platform. I usually assign a shortcut for any macro I plan to run more than a few times a week.

💡Tip: To keep your macros, save your workbook as a macro‑enabled file with the .xlsm extension, because standard .xlsx files don’t store VBA macros.

What VBA is and when you need it

The record method works well for straightforward tasks, but it has limits. If your macro needs logic or dynamic behavior, like looping through rows, checking conditions, or applying different actions based on changing data, writing VBA usually gives you that level of control. 

VBA stands for Visual Basic for Applications. It's the programming language built into Excel, and it's what the macro recorder uses behind the scenes. Writing it directly gives you more control over what your macro does.

That said, most business users don't need to learn VBA from scratch. If you need a more complex macro, there are a few practical ways to get one without writing the code yourself:

  • Use an AI tool: Describe what you want to automate to an AI tool and ask it to write the VBA for you, then paste it into the editor. There are several AI tools for Excel that can help with this. 

  • Ask a colleague: If someone on your team already works with macros regularly, it's worth asking them to build it out.

💡Tip: The one thing I'd recommend, regardless of how you get the code, is to test it on a copy of your file first. VBA gives you a lot of power, and mistakes can affect your data in ways that are hard to undo.

When should you use a macro?

You should use a macro when you repeat the same sequence of steps more than a handful of times a week. If a task takes 5 minutes manually but you do it every day, that adds up to over 30 hours a year spent on something Excel can handle automatically.

A good way to check if a task is worth automating is to ask 3 questions:

  • Do the steps stay the same every time? Macros work best when the process doesn't change. If you're making judgment calls mid-task, a macro won't capture that.

  • How often do you repeat it? A task you do 3 times a year probably isn't worth the setup time. A task you do daily or weekly almost certainly is.

  • How many steps does it involve? The longer and more repetitive the process, the more time a macro can save you.

On the flip side, macros aren't always the right tool. They can break when your data structure changes, and they may not work on another computer if security settings, platform differences, or missing dependencies get in the way. For one-off tasks or anything that changes frequently, doing it manually can be faster than maintaining a macro. 

I've found the sweet spot is recurring reporting and formatting workflows, where the structure stays consistent and the time savings add up quickly over weeks and months.

Macro security: What you need to know

Macro security matters because macros can contain code that runs automatically when you open a file, which makes them a common vector for malware. Excel disables macros by default for this reason, and I'd recommend keeping that setting in place unless you have a specific reason to change it.

When you open a file that contains macros, what Excel shows depends on where it came from. Local files trigger a yellow warning bar with an Enable Content button. Files downloaded from the internet, email, or cloud storage may show a red security risk banner and block macros entirely. Either way, make sure you trust the source before proceeding.

Here's what the main security settings mean, so you can choose the right one for your situation:

  • Disable VBA macros without notification: Excel blocks all macros silently, with no option to enable them. This is a good choice if you never use macros and want an extra layer of protection.

  • Disable VBA macros with notification: This is the default setting and the one I'd recommend for most users. Excel blocks macros but lets you enable them manually on a file-by-file basis.

  • Disable VBA macros except digitally signed macros: Excel blocks all macros except those that have been digitally signed by a trusted publisher. A good middle ground if your team uses verified macros from a known source.

  • Enable VBA macros (not recommended; potentially dangerous code can run): Excel runs all macros automatically without asking. Avoid this setting unless your IT or security team has explicitly told you to use it.

To adjust these settings on Windows, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. On Mac, go to Excel > Preferences > Security.

Common macro mistakes to avoid

Even well-built macros can cause problems if you're not careful. These are the most common mistakes to watch for:

  • Recording mistakes into the macro: The recorder captures everything, including wrong clicks and accidental formatting changes. If you make a mistake mid-recording, I recommend that you stop the macro, delete it, and start fresh rather than trying to work around it.

  • Building macros for tasks that change frequently: Macros are rigid by design. If your data structure or process changes often, your macro can break and produce incorrect results without any warning. They work best for stable, predictable workflows.

  • Using absolute references when you need relative ones: By default, the macro recorder uses absolute cell references, meaning it always performs actions on the exact cells you clicked during recording. If your data starts in a different row next time, the macro will still target the original cells. Switch to relative references in the Developer tab before recording to avoid any issues.

If your macros are mostly running data analysis, there's a faster way

Once you understand what a macro in Excel is, it's clear they work best for stable, repetitive workflows. But if most of yours are pulling data, building reports, or running the same calculations on repeat, there's a faster way. 

Julius is an AI-powered data analysis tool that handles those workflows from a plain English prompt, no recording or code required. 

Here's how Julius helps:

  • Data search: Julius can search the web for public datasets or pull structured financial data for 17,000+ companies via its Financial Datasets integration, so you can start from a question rather than an upload. 

  • Direct connections: Link databases like PostgreSQL, Snowflake, and BigQuery, or integrate with Google Ads and other business tools. You can also upload CSV or Excel files. Your analysis can reflect live data, so you’re less likely to rely on outdated spreadsheets.

  • Repeatable Notebooks: Save an analysis as a Notebook and run it again whenever you need fresh results. You can also schedule Notebooks to deliver updated outputs to email or Slack automatically.

  • Smarter over time: Julius includes a Learning Sub Agent, an AI that adapts to your database structure over time. It learns table relationships and column meanings as you work, which can help improve result accuracy.

  • Built-in visualization: Get charts and graphs on the spot instead of building them separately after your analysis.

Ready to replace your most repetitive reporting macros? Try Julius for free today.

Frequently asked questions

What is the difference between a macro and a formula in Excel?

A macro automates a sequence of actions, while a formula calculates a value based on data in your cells. Formulas sit in a cell and update when your data changes. Macros perform steps like formatting, sorting, or moving data when you run them.

Are Excel macros safe to use?

Macros you create yourself carry less risk from a security standpoint, but they can still overwrite or delete data if something is recorded or written incorrectly. Testing new macros on a copy of your workbook before running them on real data is a good habit to build. For files from external sources, only enable macros if you trust where they came from.

Can I use macros in Excel Online?

No, Excel Online can't run VBA macros the way the desktop version can. You can open a macro-enabled workbook in Excel Online, but you'll need the desktop app to actually execute them. If you need web-based automation, Microsoft offers Office Scripts as an alternative that works directly in the browser.

— Your AI for Analyzing Data & Files

Turn hours of wrestling with data into minutes on Julius.

Geometric background for CTA section