Excel Macro Not Working? Find and Fix Common Causes

VBA & macros · Updated November 2, 2026

Excel Macro Not Working? Find and Fix Common Causes

If an Excel macro is not working, first confirm that the workbook is saved in a macro-enabled format, that Excel is allowed to run its macros, and that you are opening it in the desktop app rather than Excel for the web. Then run it from Developer > Macros or press Alt+F8 on Windows (Option+F8 on Mac) and note any error message; the wording often points to the cause.

Start with the simplest checks

Before changing security settings or editing code, check a few basics. These steps resolve many cases where a macro seems missing, does nothing, or will not start:

  • Check the file type. A workbook saved as .xlsx cannot store VBA macros. Use .xlsm for a macro-enabled workbook, or .xlsb for a binary workbook that can also contain macros.
  • Use desktop Excel. Excel for the web can open a workbook containing VBA but cannot run or edit its VBA macros. Choose Open in Desktop App.
  • Enable macros only for a file you trust. If Excel displays a security warning, review where the file came from before allowing its content.
  • Confirm the macro is available. Press Alt+F8, select the macro, and choose Run. On Mac, use Option+F8 or Developer > Macros.
  • Look for a dialog or error behind the workbook. A prompt may be waiting for a response, or an error may have paused the macro in the VBA editor.

Try these checks before reinstalling Office or changing global security settings. If the macro ran before and stopped after the workbook was moved, renamed, or downloaded, file location and security are especially likely causes.

Check the workbook format and macro location

VBA code is stored inside macro-capable Excel files, not ordinary .xlsx workbooks. If someone used Save As and chose Excel Workbook (.xlsx), Excel warns that VBA will be removed; accepting that change strips the macros from the saved copy. Reopen the original .xlsm or .xlsb file if available. Renaming an .xlsx file to .xlsm does not restore code that was discarded.

Macro location also matters. A macro in a standard module in the current workbook is usually available in the Alt+F8 list. A macro stored in another open workbook, an add-in, or the Personal Macro Workbook may have a different scope. The Personal Macro Workbook, often named PERSONAL.XLSB, is hidden by design and must be open for its macros to be available. If a button is supposed to run a macro, the button may still point to a macro name or workbook that has changed.

Some procedures do not appear in the ordinary macro list. For example, a procedure declared Private, one that requires arguments, or an event procedure such as Workbook_Open is not normally run by selecting it from Alt+F8. Event procedures belong in the appropriate worksheet or ThisWorkbook code module and run in response to an event. A regular macro intended for manual use is commonly a Public Sub with no required arguments in a standard module.

Review Excel’s macro security settings

Microsoft 365 for Windows provides macro controls under File > Options > Trust Center > Trust Center Settings > Macro Settings. The exact warning or policy you see can depend on your organization’s settings and the source of the workbook. For a work computer, an administrator may control these options, so do not try to bypass a company policy.

Excel may block VBA in files marked as coming from the internet. If you trust the sender and have independently checked the file, close Excel, find the file in Windows File Explorer, right-click it, choose Properties, and look for an Unblock option on the General tab. It may not appear for every file. Unblock only a file whose source and purpose you trust; it removes a security barrier, not a VBA error. A trusted location is another option for files you use regularly, but placing a file there means Excel may trust active content in that location, so keep it restricted to appropriate files.

A warning that macros are disabled does not mean the code is broken. Conversely, enabling macros does not prove that a workbook is safe. Avoid choosing an option that enables all macros globally simply to get one file working. If Excel displays a banner, use its available content-enabling control only after deciding the workbook is trustworthy. If the control is missing or unavailable, check for an organization policy or a blocked file rather than repeatedly changing settings.

Run a small test and check whether the macro is visible

On Windows, press Alt+F8 to open the Macro dialog; on Mac, use Option+F8, or select Developer > Macros. The Developer tab may need to be enabled in Excel’s ribbon settings. If the intended macro appears, select it and run it. If it is absent, check that the right workbook is open, that the code was not removed, and that the procedure is eligible to appear in the list. In the VBA editor, opened with Alt+F11 on Windows or Option+F11 on Mac (the Fn key may also be needed on some keyboards), inspect the Project Explorer for the workbook and its modules.

If you need to distinguish a security or workbook problem from a problem in the original macro, you can try this harmless test in a standard module. Save a copy of the workbook before running any macro: macros cannot be undone with Ctrl+Z. This example only displays a message and does not change worksheet data.

Sub MacroCheck()
    Dim messageText As String

    'Confirm that a basic VBA procedure can run.
    messageText = "The test macro ran successfully."
    MsgBox messageText, vbInformation, "Macro check"
End Sub

If MacroCheck runs but the original does not, Excel can execute VBA and the issue is more likely in the original procedure, its inputs, its assigned button, or the workbook’s structure. If the test is blocked or cannot be found, revisit the file format, security warning, module location, and whether you are using desktop Excel.

Use the error message to find a VBA problem

When a macro starts and then stops, read the full error message rather than assuming Excel has disabled macros. A message such as “Subscript out of range” often indicates that code refers to a worksheet, workbook, or array item that does not exist under the name or index it expects. “Object variable or With block variable not set” usually means that an object was not assigned before the code tried to use it. A type mismatch can indicate that a value has a different data type than the code expects. These clues narrow the search; they do not identify every possible cause on their own.

Choose Debug when the error dialog offers it. The VBA editor highlights the line where execution stopped. Check the names and values used on that line, and confirm the expected sheet or range exists in the workbook that the code is actually using. In the editor, Debug > Compile VBAProject can reveal certain syntax or declaration problems before a macro runs. Compilation does not prove the macro’s logic is correct, but it can expose code that cannot be compiled.

A common source of intermittent failures is relying on whatever sheet happens to be active. A macro that uses ActiveSheet or Selection can act on the wrong tab or range if the user clicks elsewhere first. For diagnosis, compare the active workbook and sheet with the ones the macro is meant to change. Code that explicitly identifies its target workbook and worksheet is generally less dependent on what is selected, though changing code should be done carefully and on a copy.

Check buttons, events, and workbook state

If clicking a worksheet button does nothing, test the macro directly from Developer > Macros. If it runs there, the button or its assignment is a stronger suspect than the code itself. For a Forms control, right-click the button and choose Assign Macro to check which procedure it calls. ActiveX controls use a different event-code model and may be unavailable or behave differently on Mac. Also check whether the control is disabled, covered by another object, or on a protected sheet.

Automatic macros such as Workbook_Open depend on events being enabled and on the code being placed in the correct module. A prior procedure may have turned off Excel events and then stopped before turning them back on. Closing and reopening Excel can restore the usual application state, but a startup macro could disable events again. If the failure occurs only when opening the workbook, check whether Excel is showing a security warning and whether the event procedure is in ThisWorkbook rather than a standard module.

Workbook protection, read-only access, shared editing, and missing external files can also affect what a macro can change or find. A macro may run but be unable to write to a protected sheet, save to a restricted folder, or locate a file at a hard-coded path that exists only on another computer. Check the workbook’s state and the exact folder or file names the code expects. A silent-looking run may have completed without changing anything because its conditions were not met.

Consider platform and add-in differences

VBA macros run in the desktop versions of Excel for Windows and Mac, but not in Excel for the web. If a coworker opens the workbook in a browser, they may see the data and the VBA-enabled file but cannot execute that VBA there. Open the workbook in the desktop application to run it. Excel for the web has other automation options, including Office Scripts in supported Microsoft 365 environments, but Office Scripts are not VBA and are not a drop-in way to run an existing macro.

Some VBA code depends on Windows-specific features, such as COM add-ins, certain ActiveX controls, Windows API calls, or file paths written with Windows folder conventions. Such code may fail on Mac even though the VBA editor is available. In 64-bit Office, older VBA declarations that call Windows APIs may also require updates such as PtrSafe declarations. Do not add those changes blindly: the appropriate correction depends on the declaration and the code’s purpose.

Add-ins can cause confusing behavior, especially if a macro relies on one that is missing or disabled. In Windows Excel, check File > Options > Add-ins, then use the relevant Manage list and Go button to inspect Excel Add-ins or COM Add-ins. An add-in needed by the macro must be installed and enabled. To see whether an unrelated add-in is interfering, you can start Excel in Safe Mode on Windows by holding Ctrl while starting Excel and confirming the prompt, then test a copy of the workbook. Safe Mode changes the startup environment; it is a diagnostic step, not a permanent fix.

Make troubleshooting safer and more reliable

Macros can delete, overwrite, or send data, and Excel does not provide an undo history for VBA actions. Save a separate copy before running unfamiliar code, and use a small test workbook when changing a procedure. Do not run a macro merely because a file arrived from a familiar-looking email address: confirm the sender and expected contents, particularly if the file asks you to enable content unexpectedly.

Keep a simple record of what changed when troubleshooting: the file extension, whether Excel showed a warning, the macro name, the exact error, and whether the workbook works in desktop Excel. Change one thing at a time. For a workbook managed by an employer, share the error and file location with the administrator or workbook owner instead of weakening security settings. If a macro works on one computer but not another, compare Excel platform, add-ins, access permissions, file paths, and any required references.

Frequently Asked Questions

Why is my macro missing from the Alt+F8 list? Check that the workbook containing it is open and saved in a macro-capable format. The procedure may be Private, require arguments, be an event procedure, or be stored in another workbook or add-in rather than the one you expect.

Can Excel for the web run VBA macros? No. Excel for the web can open macro-enabled workbooks, but it cannot run or edit their VBA macros. Open the file in desktop Excel to use VBA.

Does saving as .xlsx disable a macro? An .xlsx file cannot retain VBA code. If you confirm a warning that removes macros when saving in that format, the saved copy will not contain them. Keep or reopen the original .xlsm or .xlsb file.

Why does a macro work on Windows but not on Mac? The code may rely on Windows-only features, an unavailable add-in, ActiveX, a Windows API, or a Windows-specific file path. Excel for Mac supports VBA, but not every Windows integration.

Can I undo a macro with Ctrl+Z? Usually not. VBA actions do not create Excel’s normal undo history, so save a separate copy before running or changing a macro that could alter data.

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.