What macros are and why Excel blocks them by default

A macro in Excel is a recorded sequence of actions — like copying data, formatting cells, or running calculations — that you can play back with a single click or keystroke. Macros save time when you repeat the same steps over and over. Excel blocks macros by default because they can be weaponized: a malicious macro can steal data, install malware, or change files without your knowledge. When you open a file with macros, Excel shows a yellow warning bar asking whether to enable them.

You only need to enable macros if you trust the file and the person or organization that sent it to you. If a stranger emails you a spreadsheet with a macro warning, do not enable it. If your company's accounting department sends you a template they built, or you created the macro yourself, it is safe to turn on.

Enabling macros is not permanent — it applies only to that one file, that one time. The next time you open the file, Excel will ask again. If you want a file to always run macros without asking, you can save it in a macro-enabled format and adjust your security settings, but that requires more steps and carries more risk.

Key Takeaways

  • When Excel shows a yellow warning bar saying "Macros have been disabled," click "Enable Content" if you trust the file and know who created it.
  • Enabling macros for one file does not turn them on for all files — Excel asks each time you open a new file with macros.
  • If you create your own macros in Excel, you can record them using the View menu or the Developer tab, then run them whenever you need them.
  • Saving a file as .xlsm (macro-enabled) instead of .xlsx (standard) tells Excel the file is meant to contain macros, but does not change security settings.
  • Never enable macros in files from unknown sources, even if the file looks legitimate — the macro runs before you see what it does.

Enabling macros when Excel shows the warning bar

When you open a file containing macros, Excel displays a yellow bar below the ribbon that says "Security Warning: Macros have been disabled." To the right of that message is a button labeled "Enable Content." Click that button to turn on the macros in that file.

After you click "Enable Content," the macros are active for as long as the file is open. If the file contains a button or menu item that runs a macro, you can now click it and the macro will execute. When you close the file and reopen it later, Excel will show the warning bar again — enabling macros does not make the setting permanent across sessions.

If you do not see a warning bar when you open a file you know contains macros, the file may be in a trusted location on your computer. Excel automatically enables macros for files stored in certain folders. You can check your trusted locations in Excel settings, but for most users, the default trusted locations are sufficient.

Changing macro security settings in Excel

If you want to adjust how strictly Excel handles macros, go to File, then Options, then Trust Center, then Trust Center Settings. In the left panel, click Macro Settings. You will see four choices: disable all macros without notification, disable all macros with notification (the default), disable all macros except digitally signed macros, and enable all macros.

Most users should leave the setting on "disable all macros with notification." This is the middle ground: macros are off by default, but you see the warning bar and can choose to enable them. Switching to "enable all macros" removes all warnings and lets any macro run automatically, which is risky if you open files from people you do not know well.

The "digitally signed" option is for organizations where IT has signed trusted macros with a certificate. Unless your workplace uses this system, that setting will not help you. If you work in an environment where macros are essential and security is managed by your IT department, ask them which setting you should use.

Creating and running your own macros

If you want to record a macro yourself, you need access to the Developer tab. By default, it is hidden. To show it, go to File, then Options, then Customize Ribbon. In the right panel under "Main Tabs," check the box next to Developer, then click OK. The Developer tab now appears in the ribbon next to the View tab.

Click the Developer tab, then click "Record Macro." A dialog box opens asking you to name the macro and choose where to store it. Name it something descriptive like "Format Sales Report" or "Copy and Paste Values." Choose "This Workbook" to store it in the current file, or "Personal Macro Workbook" to store it in a hidden file that makes the macro available in all your Excel files.

After you click OK, Excel records every action you take — every click, every keystroke, every menu selection. Perform the steps you want to automate, then go back to the Developer tab and click "Stop Recording." The macro is now saved. To run it, click "Macros" in the Developer tab, select the macro name, and click Run. You can also assign the macro to a button or keyboard shortcut for faster access.

Saving files in macro-enabled format

Excel has two main file formats: .xlsx (standard) and .xlsm (macro-enabled). A .xlsx file cannot contain macros — if you try to save a file with macros in .xlsx format, Excel will warn you and ask whether to remove the macros or save as .xlsm instead. A .xlsm file can contain macros and will preserve them when you save.

If you create a macro and want to keep it, save the file as .xlsm. Go to File, then Save As, then choose the file location. In the "Save as type" dropdown, select "Excel Macro-Enabled Workbook (.xlsm)" instead of the default "Excel Workbook (.xlsx)." Click Save. The file is now in macro-enabled format and will retain the macro when you close and reopen it.

Be aware that if you send a .xlsm file to someone else, their Excel will show the macro warning when they open it — the format does not bypass security. The format straightforward tells Excel that macros are present, so it knows to ask. The other person still has to click "Enable Content" to run the macros.

Troubleshooting when macros do not run

If you enabled macros but nothing happens when you click a button or run a macro, the macro may not be assigned to that button, or the button may be looking for a macro that does not exist. Right-click the button and select "Edit Macro" or "Assign Macro." A dialog will open showing available macros. Select the correct one and click OK.

If you do not see any macros in the list, the macro may not have been saved. Go to the Developer tab, click Macros, and check whether your macro appears in the list. If it does not, record it again, making sure to click "Stop Recording" when you are finished. If it does appear but the button is not finding it, delete the button and create a new one, then assign the macro again.

Another common issue: you recorded a macro in a file saved as .xlsx, then reopened the file and the macro was gone. This happens because .xlsx files cannot store macros — Excel silently discards them when you save. Always save files containing macros as .xlsm.

Frequently Asked Questions

Is it safe to enable macros in files from my company?

Yes, if the file came from your company's official systems or from a coworker you know. Company files are usually created internally and checked by IT. If you are unsure, ask your IT department or the person who sent you the file whether it is safe to enable macros.

What happens if I enable macros and then close the file without saving?

Nothing permanent happens. Enabling macros for that session does not change the file itself. When you reopen the file, Excel will show the warning bar again. The macro runs only while the file is open and you have enabled it.

Can I assign a keyboard shortcut to a macro I created?

Yes. Go to the Developer tab, click Macros, select your macro, then click Options. In the dialog that opens, type a letter in the "Shortcut key" field — for example, Ctrl+Shift+M. Click OK. Now you can run the macro by pressing that key combination.

Why does Excel keep asking me to enable macros even though I enabled them before?

Excel asks each time you open the file because enabling macros is a per-session setting, not a permanent one. This is intentional — it prevents a macro from running without your knowledge if someone modifies the file. If you want to stop seeing the warning, save the file as .xlsm and adjust your macro security settings, but this increases risk.

What is the difference between a macro and a formula?

A formula is a calculation you write directly in a cell, like =SUM(A1:A10). A macro is a recorded sequence of actions that can include formulas, formatting, copying, pasting, and other operations. Formulas are always safe; macros can be risky if they come from an untrusted source.