If an Excel macro will not run, first check that the workbook is saved as a macro-enabled file, that Excel has not blocked its macros, and that you are launching the correct macro. In Excel for Microsoft 365 on Windows, check the security notification near the top of the workbook, then use Developer > Macros or press Alt+F8 to select and run a macro.
Start with These Quick Checks
Before changing security settings or editing code, identify what happens when you try to run the macro. A missing macro, a security warning, an error message, and a macro that starts but appears to do nothing point to different causes. Note the exact message and whether the problem affects one workbook or every workbook.
Try these basic checks first:
- Close and reopen the workbook, then look for a security banner asking whether to enable content.
- Confirm the file is saved as an Excel Macro-Enabled Workbook (.xlsm) or Excel Binary Workbook (.xlsb), not as .xlsx.
- Open Developer > Macros and check whether the macro appears in the list. If the Developer tab is missing, enable it through File > Options > Customize Ribbon and select Developer.
- Make sure the workbook containing the macro is open. If the macro belongs to an add-in or Personal.xlsb, that file or add-in must be loaded.
- Check whether the workbook is open in Excel desktop rather than Excel for the web, which does not run VBA macros.
These steps help distinguish a blocked macro from one Excel cannot find, one that contains an error, or one that the current version of Excel cannot run.
Check the Workbook File Type
The standard .xlsx format cannot store VBA macro code. If you choose .xlsx when saving a workbook that contains macros, Excel warns that VBA projects cannot be saved in that format. If you proceed, the macro code is removed from the saved copy. The original file may still have its code, so check which copy you opened and avoid overwriting the only macro-enabled version.
To preserve macros, use File > Save As and select Excel Macro-Enabled Workbook (*.xlsm), or Excel Binary Workbook (*.xlsb) if that format suits your workflow. Renaming a file from .xlsx to .xlsm does not restore missing VBA code; the code must still exist in the workbook. If you received the file from someone else, ask them to provide the macro-enabled version.
A workbook saved as .xlsm can still have macros blocked by security settings. The file extension means it can contain VBA; it does not mean Excel will automatically allow the code to run.
Understand Excel’s Macro Security Warning
Excel may disable macros because VBA code can change files, access data, or perform other actions. If a trusted workbook opens with a security notification, choose Enable Content only when you trust the source and expected the file to contain macros. If you do not recognize the sender or cannot verify what the workbook does, leave the macros disabled and confirm its purpose before proceeding.
On Windows, macro settings are in File > Options > Trust Center > Trust Center Settings > Macro Settings. If Disable VBA macros with notification is selected, Excel can show a warning that lets you decide whether to enable macros for a particular file. If macros are disabled without notification, the workbook may open without an obvious prompt. Settings such as disabling macros except digitally signed macros may also prevent a particular file from running.
Do not turn on Enable VBA macros globally just to get one workbook working. That setting can allow macros in other files too. In a work or school installation, an administrator may control these settings through policy, in which case the options may be unavailable or a changed setting may not take effect. Ask the organization’s IT administrator about approved files and locations instead of trying to bypass its controls.
Files Downloaded From the Internet
Windows and Office can treat files obtained from the internet or other untrusted locations as potentially unsafe. A workbook may show a message that Microsoft has blocked macros because the source is untrusted, rather than the usual prompt to enable content. A downloaded workbook can also open in Protected View, which limits editing until you choose to trust the file.
If you know the file is legitimate, verify its source and scan it according to your organization’s rules. For a file you have deliberately chosen to trust, close Excel, find the workbook in File Explorer, right-click it, choose Properties, and look on the General tab for an Unblock option. If it is present, selecting it and applying the change may allow Office to treat the file differently when reopened. This option is not available for every file, and organizational policy can still block the macro.
Do not unblock an unexpected attachment simply because a workbook needs a macro. Protected View and internet-based blocking exist to reduce the risk of running harmful code. If the file came in a ZIP archive or through a managed document service, the right steps can depend on how it was downloaded and on your organization’s setup.
Launch the Right Macro
In desktop Excel for Windows, open Developer > Macros, select a macro, and choose Run. Alt+F8 opens the Macro dialog. If Developer is not visible, turn it on through File > Options > Customize Ribbon. On Mac, the Developer tab can also be used; Excel’s Tools > Macro menu provides macro commands, and keyboard shortcuts can vary with the keyboard and macOS settings.
If the macro does not appear in the list, check its location and how it is written. The dialog generally lists eligible public procedures that take no arguments and are stored in a standard VBA module. A procedure that requires an input argument, or code placed in a worksheet or ThisWorkbook module, may not appear as a macro to run directly. Event procedures such as Workbook_Open are designed to run in response to an event rather than from the regular macro list.
If you use a worksheet button or shape, right-click it and choose Assign Macro to check which procedure it calls. The assigned macro might have been renamed, deleted, or stored in a workbook that is no longer open. For a button on the Developer tab, inspect its assigned macro as well. A clickable shape is not proof that the code it refers to is available or enabled.
Diagnose Errors and Code Problems
If Excel displays a compile error, runtime error, or a Visual Basic Editor window, the macro has usually been found and VBA has begun processing it. Read the full error message and note the highlighted line. A compile error prevents code from running correctly; a runtime error occurs while the procedure is executing, often because an expected sheet, range, file, or value is unavailable.
Common code-related causes include:
- A worksheet or workbook name in the code no longer matches the actual name.
- The macro expects a particular cell, file path, table, or data format that has changed.
- A required reference is missing. In the Visual Basic Editor, a reference marked MISSING under Tools > References may stop code that depends on it from compiling.
- The procedure is paused at a breakpoint, or VBA is in Break mode after an earlier error.
- The code uses Windows-specific components, external libraries, or controls that are unavailable on the current computer.
In the Visual Basic Editor, use Debug > Compile VBAProject to check for compile problems. If an error opens the editor, do not simply keep clicking Run: inspect the highlighted statement and its inputs. If you are not the code’s author, ask the author what the macro expects and whether its dependencies are installed. Repairing code without understanding its purpose can produce incorrect results or unintended changes.
For a macro that runs without an error but seems to do nothing, inspect its conditions and inputs. It might exit early when a required cell is blank, work only on a particular sheet, or place results somewhere other than the active worksheet. A message box or a carefully reviewed line-by-line check in the editor can help identify the path the code takes, but only run code you trust.
Check Workbook Events and Excel State
Some macros are triggered by events rather than by a manual click. For example, Workbook_Open runs when a workbook opens, and worksheet event procedures respond to changes or selections on a sheet. These procedures must be placed in the appropriate workbook or worksheet code module. If an event does not fire, check that the event code is in the right place and that macros were enabled when the file opened.
VBA can also turn off Excel events with Application.EnableEvents = False. If code stops unexpectedly after doing that, event-driven procedures may remain inactive for the current Excel session. A developer can inspect the setting in the Visual Basic Editor’s Immediate window, but changing application state or running repair code should be done only when the cause is understood. If you are not comfortable with VBA, close Excel and reopen it, then contact the workbook’s author rather than pasting in an unfamiliar fix.
Other state issues can make a working macro appear stuck: Excel may be waiting for a dialog response, a calculation may be taking time, or the procedure may be waiting for an external file or connection. Check for open dialogs and the status bar before assuming the code has failed. If Excel is unresponsive, allow reasonable time for a large task to finish before force-quitting, since closing it may interrupt work.
Excel for the Web, Mac, and Compatibility
Excel for the web can open and edit many macro-enabled workbooks, but it cannot create, run, or edit VBA macros. Open the workbook in the Excel desktop app to run its VBA. If you are using a browser and do not see the expected macro controls, switching to desktop Excel is the key step, not changing the workbook’s security settings.
Excel for Mac supports VBA, but not every Windows-specific feature is available. A macro that relies on Windows API calls, ActiveX controls, COM add-ins, or particular Windows paths may work on a Windows PC and fail on a Mac. Macros that use ordinary worksheet operations are more likely to be portable, but compatibility depends on their code and dependencies. Ask the author whether a Mac-compatible version exists.
Excel’s security menus and some keyboard shortcuts can differ by platform and release. On Mac, review Excel’s Security or macro security preferences if a macro is blocked; the available controls and labels are not identical to Windows Trust Center settings. Do not assume a Windows troubleshooting path applies exactly to Mac, and remember that browser-based Excel does not run VBA on either platform.
Run Macros Safely and Keep a Recovery Copy
Macros can edit or delete worksheet data, change files, and interact with other parts of a computer. Before running an unfamiliar macro, check who supplied it, what task it is intended to perform, and whether the source is trustworthy. In a workplace, follow your organization’s approved process for reviewing and enabling macro files.
Save a separate copy of the workbook before running a macro that changes data. VBA actions generally cannot be undone with Ctrl+Z, and Excel’s undo history may be cleared when a macro runs. Keep the original untouched so you can compare results or restore the starting data if the macro behaves unexpectedly. This safeguard is useful even for a familiar macro when it processes many sheets or files.
If the macro comes from a third party, ask for a description of the operations it performs and any required add-ins or files. A digital signature can help identify whether signed code has changed since it was signed, but a signature alone does not prove that code is harmless. Security warnings should be treated as a reason to verify, not as a routine obstacle to dismiss.
Frequently Asked Questions
Why is Enable Content missing in Excel?
Macros may be blocked without a notification, the file may have been marked as coming from an untrusted internet source, or an administrator may enforce a policy. Check the exact warning, the workbook’s source, and the approved security settings for your device.
Why does my macro not appear in the Macro dialog?
It may be in a different workbook or an unloaded add-in, or it may be an event procedure rather than a macro intended for manual selection. Macros that require arguments or are not public procedures in a standard module may also be absent from the list.
Can I run an Excel macro in a browser?
No. Excel for the web can work with many macro-enabled workbooks but does not run VBA. Open the workbook in the Excel desktop app to use its VBA macros.
Will changing .xlsx to .xlsm restore a macro?
No. Changing the filename extension does not bring back code that was removed when the workbook was saved as .xlsx. You need a copy that still contains the VBA project, saved in a macro-enabled format.
Why does a macro work on Windows but not on a Mac?
The code may depend on Windows-only controls, APIs, add-ins, file paths, or other components. Excel for Mac supports VBA, but it does not provide every Windows feature. Ask the macro’s author about platform compatibility.
Can I undo a macro with Ctrl+Z?
Usually not. Running VBA generally clears Excel’s undo history, so save a separate copy before running a macro that may change workbook contents.
Related
- Excel: How to Calculate Workdays Between Two Dates
- Excel Highlight Dates Older Than Today Automatically
- Excel Highlight Keyboard Shortcut: What Actually Works
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Range Is Nothing? Meaning, Checks, and Common FixesIn Excel VBA, a Range is Nothing when an object variable does not currently refer to a range…
- VBA Dictionary Example: Create, Find, and Count ItemsA VBA dictionary stores unique keys with associated values, making it useful for counting repeated entries or looking…
- Excel UserForm: How to Show It with VBATo show an Excel UserForm, create the form in the Visual Basic Editor, then run a VBA procedure…
- Excel VBA Subscript Out of Range: Causes and FixesExcel VBA “Run-time error 9: Subscript out of range” means your code asked for an item that does…
- Excel VBA: Copy a Worksheet and Rename ItTo copy a worksheet and rename the copy with VBA, use the worksheet’s Copy method, then set the…
- VBA to Save Excel Tabs as Separate FilesYes. A VBA macro can copy each visible worksheet tab into a new workbook and save it as…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.