Excel won’t run your macro? The most common cause is that macros are disabled by default for security, and the fix is to enable them via the Trust Center or the security warning bar. But there are several other reasons a macro may fail to run, each with a specific solution—this article walks you through all of them.
Why Excel Blocks Macros by Default
Since 2006, Microsoft has disabled macros by default in Excel to protect users from malicious code. A macro is a small program written in VBA (Visual Basic for Applications), and it can do anything from formatting a cell to deleting files. Because of that power, Excel treats any workbook containing macros as a potential threat. When you open a file with a macro, you’ll see a yellow bar under the ribbon that says “SECURITY WARNING Macros have been disabled.” This is not a bug—it’s a safety feature. To run the macro, click the “Enable Content” button on that bar. If the bar is missing, go to File > Options > Trust Center > Trust Center Settings > Macro Settings, and select “Enable all macros” (not recommended) or “Disable macros with notification.” The latter is the safer choice because it lets you decide per file.
How to Check if Macros Are Enabled
Before troubleshooting further, confirm that macros are actually enabled in your Excel settings. Open a blank workbook, press Alt+F11 to open the VBA editor. If the editor opens, VBA is installed. Then go to Tools > Macro Security (in the VBA editor) and ensure it’s not set to “Disable all macros without notification.” Back in Excel, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. The recommended setting is “Disable macros with notification”—this shows the security warning bar so you can enable macros per file. If you’ve set it to “Enable all macros,” Excel will run any macro without asking, which is convenient but risky. For workbooks you trust, you can also right-click the file in File Explorer, select Properties, and check “Unblock” if the file was downloaded from the internet—this removes the Mark of the Web that triggers the warning.
Common Reasons a Macro Won’t Run
Even with macros enabled, a macro may fail to run. Here are the most frequent causes and their fixes:
- File format: The workbook must be saved as a macro-enabled file, i.e., .xlsm, not .xlsx. If it’s .xlsx, Excel strips macros when saving. Save as .xlsm via File > Save As > Excel Macro-Enabled Workbook.
- Macro location: If the macro is in a different workbook, it won’t run unless that workbook is open. If it’s in your Personal Macro Workbook (PERSONAL.XLSB), it’s available to all workbooks, but only if that file is not hidden or corrupted.
- Trusted Locations: If the file is in a Trusted Location, macros run automatically without prompts. To add a folder, go to File > Options > Trust Center > Trust Center Settings > Trusted Locations, and add your folder. But be careful—any macro in that folder will run without warning.
- Protected View: Files from the internet or email may open in Protected View, a read-only mode that blocks macros. Click “Enable Editing” on the yellow bar to exit Protected View, then enable content.
- Corrupted VBA project: If the macro worked before but now doesn’t, the VBA project may be corrupted. You can try to export the modules and import them into a new workbook, or use a backup.
How to Run a Macro Manually
If the macro is enabled but you don’t know how to run it, here are the ways:
- Press
Alt+F8to open the Macro dialog box. Select the macro name and click “Run.” - Assign the macro to a button or shape: right-click the shape, choose “Assign Macro,” and select the macro.
- Use a keyboard shortcut: in the Macro dialog, click “Options” to assign a Ctrl+key combination.
- Run from the VBA editor: press
Alt+F11, place the cursor inside the macro code, and pressF5.
If the macro doesn’t appear in the list, it might be in a different workbook or it might be a worksheet event macro (like Worksheet_Change) that runs automatically on a trigger, not manually.
Security vs. Functionality: Making the Right Choice
The tension between security and convenience is real. If you disable all macros, you’re safe but can’t run any automation. If you enable all, you risk running malicious code. The best practice is to keep “Disable macros with notification” and only enable content for files you trust. For files you create yourself, you can sign them with a digital certificate (self-signed via SelfCert.exe that comes with Office) and then add that certificate to the Trusted Publishers list. This way, your macros run without prompts, but unknown macros still trigger warnings. Never disable all macros permanently unless you fully understand the risk.
Comparing Excel Versions and Platforms
Macro behavior differs across Excel versions and platforms. In Excel for Microsoft 365 (Windows), the steps above apply. On a Mac, the Trust Center is at Excel > Preferences > Security & Privacy. The security warning bar appears similarly. Excel for the web does not support VBA macros at all—you can view them but not run them. Excel for mobile apps also don’t run macros. If you need macros on a Mac, ensure you have the full desktop version, not the App Store version which is limited. Also, 64-bit Excel can run most 32-bit macros, but some API calls may need adjustment.
What to Do When a Macro Still Won’t Run
If you’ve tried everything and the macro still fails, try these advanced steps:
- Check for errors: In the VBA editor, press
Ctrl+Gto open the Immediate window and look for error messages. Also, use Debug > Compile VBAProject to catch syntax errors. - Repair Office: Go to Control Panel > Programs > Programs and Features, select Microsoft Office, and choose “Change” then “Quick Repair.” This can fix corrupted installation files.
- Reset Excel settings: Sometimes a corrupted Excel settings file causes issues. Close Excel, rename the
Excel.xlbfile (Windows) orcom.microsoft.Excel.plist(Mac) to .bak, then restart Excel. - Check for add-ins: A problematic add-in can interfere. Disable all add-ins via File > Options > Add-Ins, select “COM Add-ins,” uncheck all, and restart.
If the macro is from a third-party, contact the vendor for support. Also, remember that macros cannot be undone with Ctrl+Z, so always save a copy of your workbook before running a new macro.
Frequently Asked Questions
Why is my macro grayed out in the Macro dialog? A grayed-out macro usually means the workbook is in a state that doesn’t allow editing, like Protected View or a read-only file. Click “Enable Editing” or save a copy to your local drive. Also, if the macro is in a different workbook, it won’t be available unless that workbook is open.
How do I enable macros permanently for a specific file? You can’t enable macros permanently for a single file without a digital signature. The closest is to place the file in a Trusted Location, but that applies to all files in that folder. Alternatively, sign the macro with a self-signed certificate and add it to Trusted Publishers.
Can I run a macro from a .xlsx file? No. .xlsx files cannot contain macros. If you try to save a macro-enabled workbook as .xlsx, Excel will warn you that macros will be removed. Always save as .xlsm to keep macros.
Why does Excel say “Macros are disabled” even after I enabled them? This can happen if the file has the Mark of the Web (downloaded from internet) and you haven’t unblocked it. Right-click the file in File Explorer, select Properties, and check “Unblock” at the bottom. Also, check that your macro settings aren’t overridden by group policy if you’re on a corporate computer.
What is the difference between a macro and an add-in? A macro is a single VBA procedure stored in a workbook. An add-in is a special workbook with the .xlam extension that loads into memory and makes its functions available globally. Add-ins can contain macros, but they are installed via File > Options > Add-Ins, not run directly.
Related
- Excel Inventory Template: How to Track Stock
- Excel Template Job Schedule: How to Build One
- Excel Template for Weekly Employee Schedule: How to Build One
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel Macro to Protect a Sheet With a PasswordTo protect the active worksheet with a password in Excel for Microsoft 365 on Windows, run a VBA…
- Excel VBA Delete Whole Row: Safe Methods and ExamplesTo delete an entire worksheet row with VBA, use Rows(row_number).Delete, such as Rows(5).Delete for row 5. In a…
- Excel VBA InputBox Cancel: Exit a Sub SafelyYes. To stop the current Excel VBA procedure when a user cancels an input box, test the returned…
- Excel VBA Array of Worksheets: Create and Use OneIn Excel VBA, you can work with several worksheets as a group by passing an array of sheet…
- Excel VBA INDEX: Return Values from a RangeIn Excel VBA, “INDEX” usually means Excel’s INDEX worksheet function, called as Application.WorksheetFunction.Index(...) or Application.Index(...) to return an…
- Excel VBA: Open a CSV and Copy Its Data to a SheetTo open a CSV file with Excel VBA and copy its data into a worksheet, use Workbooks.OpenText to…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.