Cannot Run a Macro in Excel? Fix Common Causes

VBA & macros · Updated November 21, 2026

If you cannot run a macro in Excel, first confirm that the workbook is saved in a macro-capable format, then check whether Excel has blocked the macro or whether the macro is available in the workbook you are using. In Microsoft 365 for Windows, start with the yellow security warning or File > Options > Trust Center > Trust Center Settings, but enable macros only when you trust the file and its source.

Why Excel may not run a macro

Excel can stop a macro for several different reasons, and the message does not always identify which one applies. A macro may be disabled by security settings, removed when a workbook was saved in the wrong format, absent from the workbook, or unavailable because a button still points to an old macro name. A company policy can also block macros regardless of the setting a user chooses.

One common message is “Cannot run the macro… The macro may not be available in this workbook or all macros may be disabled.” Treat this as a clue, not a diagnosis: the macro could be disabled, but Excel may also be unable to find the named procedure. A useful first test is to open the workbook in the desktop Excel app, check for a security warning, and press Alt+F8 to see whether the expected macro appears in the list.

Check the workbook file type

VBA macros need a file format that can store them. A workbook saved as .xlsx does not retain VBA code. If you choose that format for a macro-enabled workbook, Excel warns that VBA projects cannot be saved in a macro-free workbook; continuing can remove the macros. Common formats that can contain VBA include .xlsm for an Excel macro-enabled workbook, .xlsb for an Excel binary workbook, and .xlam for an Excel add-in.

Check the file name in Excel’s title bar or use File > Save As to inspect its type. If the workbook should contain macros but ends in .xlsx, locate an original macro-enabled copy or ask its creator for one. Changing the extension by renaming the file does not restore deleted code. If you are saving a workbook that already contains VBA, select Excel Macro-Enabled Workbook (*.xlsm) unless you have a specific reason to use another macro-capable format.

Enable macros only for a trusted file

In Windows desktop Excel, a notification bar may appear below the ribbon when a workbook opens with macros disabled. If you know and trust the sender and have verified that the workbook is expected, use the bar’s Enable Content control. Do not enable macros simply because a file asks you to: VBA can change files, access data, and perform other actions available to the user running Excel.

If no notification appears, review File > Options > Trust Center > Trust Center Settings > Macro Settings. The setting may be controlled by your organization, and changing it to enable all VBA macros is not a safe general fix. A safer configuration is to keep macros disabled with notification, then allow a macro only when you have a good reason to trust that workbook. The exact choices shown can vary with Office policy and updates.

Files downloaded from the internet can receive extra protection in Windows. If a trusted workbook is blocked, close Excel, locate the file in File Explorer, right-click it, choose Properties, and look on the General tab for an Unblock option. Use this only for a file from a source you trust; then reopen it. If Unblock is absent, or a message says the setting is managed by an administrator, do not try to bypass the restriction. Ask your IT administrator or the file’s sender for an approved copy or process.

Make sure the macro is in the workbook you expect

Press Alt+F8 in Excel for Windows to open the Macro dialog. Check the Macros in list: it may be set to the current workbook, all open workbooks, or another location. A macro might be stored in Personal.xlsb, an add-in, or a different open workbook rather than in the file you are looking at. Select the relevant location and check whether the macro appears.

Most macros listed in that dialog are public procedures without arguments in a standard VBA module. A procedure declared Private, a procedure that requires arguments, or code placed in a worksheet or workbook event module may not appear as a normal runnable macro. Event procedures, such as code that runs when a worksheet changes, are triggered by the relevant event rather than launched from Alt+F8. If you did not write the code, ask its author where the macro is stored and how it is intended to run.

To inspect code, open the VBA editor with Alt+F11 and look in the Project Explorer for the intended workbook. The Developer tab can be shown through File > Options > Customize Ribbon by checking Developer. Do not edit unfamiliar code just to make it appear in the list. If the workbook is protected or the project is unavailable, contact its owner instead of attempting to defeat that protection.

Repair a button or shortcut that no longer works

A workbook can contain a shape, form control, or shortcut that is assigned to a macro name that has changed or was deleted. If Alt+F8 shows the macro and you can run it there, but clicking the workbook’s button fails, the assignment is a likely cause. For a shape or form control, right-click it and choose Assign Macro; select the correct procedure if it is present. The available commands differ for ActiveX controls, which are managed through the Developer tab and design mode.

Buttons can also refer to a workbook name or macro that belonged to an earlier copy of the file. For example, a button might still be assigned to a procedure in a workbook that has been renamed or is no longer open. Have the workbook’s maintainer check and update the assignment rather than running a similarly named procedure at random. Save a copy before making changes, especially if the workbook is important.

Understand errors that appear after a macro starts

If Excel begins running the macro and then displays a VBA error, macros are probably enabled and available; the problem is now in execution. A message such as “Run-time error” may result from missing input data, a renamed worksheet, a file path that is unavailable, or a value the code does not expect. Choose Debug only if you are comfortable inspecting code, or record the full error and the step that triggered it for the macro’s author.

Some procedures rely on a particular workbook being active, a specific worksheet name, or another file being open. For example, code that refers to a sheet named “Summary” will fail if someone renamed that tab. An error can also occur because an add-in or external reference is missing. Avoid changing the workbook’s structure or clicking through error prompts without understanding the effect; the macro may have made some changes before it stopped.

When workplace security or Excel for the web is involved

In a managed Microsoft 365 environment, an administrator can set policies that override the user’s Trust Center choices or block internet-sourced VBA. If macro settings appear unavailable, are grayed out, or revert after a change, contact IT. Ask whether the workbook can be digitally signed, distributed through an approved location, or replaced with a sanctioned alternative. A digital signature can help establish who published code and whether it has changed, but it does not prove that the code is harmless.

Excel for the web does not run VBA macros. Opening a macro-enabled workbook in a browser is therefore not a way to test whether the VBA works; use the desktop Excel application on a supported computer. The browser version may let you work with workbook data, but it cannot execute the VBA project. On a Mac, use desktop Excel and check its macro security controls under Excel > Settings or Preferences > Security; labels can vary by release. Windows instructions such as File > Options do not apply to Mac.

Use a safe troubleshooting sequence

Work through these checks in order. This helps separate a security block from a missing macro or a broken control without lowering protection for every workbook:

  • Confirm you are using desktop Excel, not Excel for the web, and verify that the file is a macro-capable format such as .xlsm.
  • Check for a security notification and verify the workbook’s source before allowing its content.
  • Use Alt+F8 to check whether the macro appears and whether the correct workbook is selected in the Macro dialog.
  • If the macro appears, run it directly once, provided you trust it. If direct execution works but a button fails, investigate the button’s assignment.
  • If a VBA error appears, note its exact wording and the action that produced it. This points to an execution problem rather than a macro that Excel cannot find.
  • If policy blocks the file or controls are unavailable, ask the administrator or workbook owner for help rather than enabling all macros.

Before running any unfamiliar macro, save a separate copy of the workbook. VBA actions cannot be undone with Ctrl+Z, and a macro may change or delete data. A backup gives you a recovery point if the code behaves unexpectedly.

Alternatives when VBA is not suitable

If you only need to automate a repeatable task, VBA is not always necessary. Excel’s built-in features may be enough for sorting, filtering, formatting, or simple calculations. Power Query can help import and reshape data, while Office Scripts can automate certain tasks in supported Microsoft 365 environments. Availability and capabilities depend on your account, platform, and organizational settings, and these alternatives are not drop-in replacements for every VBA project.

For a workbook shared with people who use Excel for the web, a solution that does not depend on VBA may be more practical. Ask what the automation is meant to do before replacing it: a macro that edits many sheets or interacts with files may need a different design from one that simply refreshes and formats a table. Do not convert or remove a working macro until you understand the workflow and have retained a safe original copy.

Frequently Asked Questions

Why does Excel say the macro may not be available?
Excel may have disabled macros, may not find the procedure in the selected workbook, or may be dealing with a broken button assignment. Check the security warning and use Alt+F8 to see whether the macro is listed in the expected location.

How do I enable macros in Excel safely?
Only enable content for a workbook you trust and expected to receive. In Windows, use the notification bar’s Enable Content control when appropriate, rather than setting Trust Center to enable all macros. If a policy blocks the file, ask your administrator for an approved route.

Can an .xlsx file run a VBA macro?
An .xlsx workbook cannot store a VBA project. Find the original .xlsm, .xlsb, or other macro-capable file. Renaming an .xlsx file does not bring back code that was removed when it was saved.

Can I run an Excel macro in a browser?
No. Excel for the web does not execute VBA macros. Open the workbook in desktop Excel to run its VBA, subject to the workbook’s security settings and your organization’s policies.

Why does a macro button fail when the macro is listed?
The button may be assigned to a deleted procedure, a differently named macro, or a macro in another workbook. If the macro runs from Alt+F8 but not from the button, check Assign Macro or ask the workbook’s owner to repair the control.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.