If your macro isn't running in Excel, the cause is almost always one of four things: macros are disabled for the file, the file was opened from an untrusted location, the macro is stored in a module that isn't being called, or Excel is in a state (protected view, design mode, or a paused error) that blocks execution. Work through the checks below in order — most people find the problem in the first three steps.
What You'll Need
- Excel on Windows or Mac (the exact menu labels differ slightly by version, device and region — this guide uses the Windows desktop ribbon, which is the most common setup)
- The workbook containing the macro, saved as .xlsm or .xlsb (macro-enabled formats)
- Permission to change Trust Center settings on your machine
Step-by-Step
- Check the file format. A macro saved in a standard .xlsx file is stripped out on save. Confirm the file name ends in .xlsm or .xlsb. If it ends in .xlsx, the code may already be gone — you will need to restore a backup or re-add the macro and save as .xlsm.
- Look for the security warning bar. When you open a macro-enabled file, Excel may show a yellow bar under the ribbon saying macros have been disabled. Click Enable Content. If the bar does not appear, macros may be blocked entirely — continue to the next step.
- Check Trust Center macro settings. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. The recommended setting is Disable all macros with notification, which lets you enable them per file. If it is set to Disable all macros without notification, your macros will never run and you will see no warning. Change it to the notification option, then close and reopen the file.
- Check Protected View and file location. Files downloaded from the internet or email often open in Protected View, where macros cannot run. Look at the top of the window — if it says Protected View, click Enable Editing. Also move the file out of your Downloads folder into a normal Documents folder; files in certain locations are treated as untrusted.
- Confirm you are actually triggering the macro. Press Alt+F8 to open the Macro dialog. Your macro should be listed. Select it and click Run. If it runs from here but not from your button or shortcut, the problem is the trigger (a shape or button pointing at the wrong macro name, or a shortcut key conflict), not the code.
- Check where the code lives. Press Alt+F11 to open the Visual Basic Editor. In the Project pane, look under Modules. If your code is in ThisWorkbook or a sheet module but is written as a normal
Sub, it may not be reachable from the Macro dialog. Move general-purpose code into a standard module (Insert > Module). - Turn off Design Mode. On the Developer tab, if Design Mode is highlighted, click it to turn it off. While Design Mode is on, controls on the sheet will not fire their assigned macros.
- Look for a hidden error or paused code. In the Visual Basic Editor, press F5 or use Run > Reset to clear any paused state. Then step through the macro with F8 to find the line where it stops. A runtime error dialog that was dismissed can leave the macro silently halted.
- Check for missing references. In the Visual Basic Editor, go to Tools > References. Any item marked MISSING will stop the macro from compiling. Untick it, or re-add the correct library.
- Test in a fresh session. Save your work, close Excel completely, reopen the file, enable content, and run the macro again. A stuck Excel process or an add-in conflict can block execution until restart.
Common Mistakes
- Saving macro code in an .xlsx file and wondering why it disappears — always use .xlsm.
- Clicking Enable Content once and assuming it sticks for every copy of the file; each new download or emailed copy may prompt again.
- Assigning a macro to a button but picking a similarly named macro from the list.
- Leaving Design Mode on after editing controls.
- Ignoring the yellow warning bar because it is scrolled out of view — widen the window or check just below the ribbon.
Tips
- Keep a trusted location for your macro workbooks: File > Options > Trust Center > Trust Center Settings > Trusted Locations. Files there skip the security prompt.
- Use Alt+F8 first whenever a macro misbehaves — it tells you instantly whether Excel can see the macro at all.
- Name macros without spaces and avoid names that clash with cell references or reserved words.
- If you share the file, tell recipients to enable macros; otherwise they will see a blank or unchanged sheet.
Troubleshooting
If the macro still does not run after the steps above, work from simplest to most disruptive:
- Restart Excel and your computer. This clears stuck processes and add-in conflicts.
- Disable add-ins temporarily. File > Options > Add-ins, then manage Excel Add-ins and COM Add-ins. Turn them off one at a time to find a conflict, and turn them back on afterwards.
- Repair Office. Use the Windows Settings > Apps > Microsoft 365 > Modify > Repair option. Choose Quick Repair first; it does not delete your files.
- Rebuild the file. Copy your data into a new .xlsm workbook and re-import the code. This is the last resort and is safe for your data as long as you keep the original.
If the macro runs on another computer but not yours, the difference is almost always Trust Center settings or a missing reference library, not the code itself.
Frequently Asked Questions
Why does my macro run from Alt+F8 but not from my button?
The button is assigned to a different macro name than the one you are testing. Right-click the button, choose Assign Macro, and pick the correct entry.
Why is the Macro dialog empty?
Excel only lists public Subs in standard modules. If your code is in a sheet module, is marked Private, or takes arguments, it will not appear. Move it to a standard module and remove any arguments.
Can I stop the security warning appearing every time?
Yes — place the workbook in a folder you have added as a Trusted Location in Trust Center. Only do this for files you created or trust.
Does this work the same on Mac?
The concepts are the same, but menu paths differ: on Mac, look under the Excel menu for Preferences > Security rather than File > Options > Trust Center.
Will enabling macros harm my computer?
Macros can run any code the author wrote, so only enable them in files from sources you trust. If you are unsure of a file's origin, do not enable content.