Excel VBA Macro Not Running? Fixes That Work

VBA & macros · Updated November 22, 2026

If your Excel VBA macro is not running, the most common causes are macros being disabled by security settings, the workbook being saved as a non-macro file type, or the macro being placed in the wrong module. Check the Trust Center settings (File > Options > Trust Center > Trust Center Settings > Macro Settings) and enable “Enable all macros,” then save the file as .xlsm or .xlsb. If it still won’t run, press Alt+F11 to open the VBA editor and step through the code with F8 to find the exact line that fails.

Why Macros Stop Working: The Usual Suspects

Before diving into complex debugging, understand that Excel intentionally blocks macros by default. Since 2007, Microsoft has treated macros as a security risk because they can contain malicious code. When you open a workbook with macros, Excel displays a yellow bar with an “Enable Content” button. If you ignore it, the macros are disabled for that session. Also, if the file extension is .xlsx (not .xlsm), Excel strips out all VBA code when saving, so the macro literally doesn’t exist in the file anymore. Another frequent issue: the macro is stored in the Personal Macro Workbook (PERSONAL.XLSB), which must be visible and enabled in the VBA project explorer.

How VBA Macros Are Supposed to Run

VBA macros run in response to an event or when you manually trigger them. A macro can be a Sub procedure (runs a sequence of actions) or a Function (returns a value). To run a macro manually, you can press Alt+F8, select the macro name, and click Run. You can also assign a macro to a button or shape, or use a keyboard shortcut. For automatic execution, you can use the Workbook_Open event in the ThisWorkbook module, or Worksheet_Change in a sheet module. If a macro is not running, first confirm it appears in the Alt+F8 list. If it doesn’t, it’s not in a standard module—it might be in a sheet module or a class module, which won’t show up in the macro list unless you call it from another macro.

Security Settings and How to Change Them

Excel’s Trust Center controls macro execution. To enable macros permanently for your own files, go to File > Options > Trust Center > Trust Center Settings > Macro Settings, then select “Enable all macros” (not recommended for files from unknown sources) or “Disable all macros with notification” (the default, which shows the yellow bar). For a single file, click “Enable Content” on the warning bar. If the bar doesn’t appear, check the file’s properties: right-click the file in Windows Explorer, select Properties, and if it says “This file came from another computer,” click Unblock. This is a common issue for downloaded workbooks. On a Mac, go to Tools > Macro > Security and set the level to Medium or Low (or use the notification option).

Common Code Errors That Stop Macros

Even with security enabled, your macro might fail due to syntax errors, runtime errors, or logic bugs. A syntax error appears as a dialog box when you try to run the macro, and the offending line is highlighted in red. Common syntax mistakes: missing End If, misspelled variable names, or mismatched parentheses. Runtime errors (like “Subscript out of range” or “Object required”) occur when the code tries to reference a sheet, range, or object that doesn’t exist. For example, Sheets("Data").Range("A1") fails if there is no sheet named “Data.” To debug, press F8 to step through the code line by line, and hover over variables to see their current values. Also, use Debug.Print to output values to the Immediate Window (Ctrl+G).

How to Check If the Macro Is Actually There

Open the VBA editor with Alt+F11. In the Project Explorer (left pane), expand the VBAProject for your workbook. Look under Modules—if you don’t see a module, right-click on the project, select Insert > Module, and paste your code there. If you see the module but the macro doesn’t appear in Alt+F8, the macro might be declared as Private Sub—that’s fine, but it won’t show in the list. To make it visible, change it to Public Sub or just Sub. Also check if the macro is in the wrong workbook: if you have multiple workbooks open, the macro might be stored in a different one. Use the “Macros in” dropdown in the Alt+F8 dialog to select the correct workbook.

Fixing Macros That Run but Do Nothing

Sometimes the macro runs without errors but doesn’t produce the expected result. This often happens when the code references a specific worksheet or range that isn’t active. For example, Range("A1").Value = 5 affects the active sheet, which might not be the one you intended. To be safe, always qualify ranges with a worksheet object, like ThisWorkbook.Sheets("Data").Range("A1").Value = 5. Another issue: the macro might be changing a cell but the calculation mode is set to Manual, so the displayed values don’t update. Set Application.Calculation = xlCalculationAutomatic at the start of your macro. Also, check if the macro is being interrupted by an error handler: if you have On Error Resume Next, errors are silently ignored, making it seem like nothing happened. Temporarily comment it out to see the real error.

When Macros Are Disabled by Group Policy

In corporate environments, IT administrators can enforce macro settings via Group Policy, overriding local Trust Center settings. If you’ve enabled macros but they still don’t run, check with your IT department. You can test this by trying to run a macro in a brand-new workbook you create yourself. If that works, your settings are fine; the issue is specific to the file. If even a new macro fails, your Excel installation might have a corrupted Trust Center registry key. Try repairing Office via Control Panel > Programs > Microsoft 365 > Change > Quick Repair. On a Mac, reinstall Office or reset preferences. Also, note that macros are completely disabled in Excel for the web (browser version); you must open the file in the desktop app.

Frequently Asked Questions

Why does my macro run in one workbook but not another? The macro might be stored in the first workbook’s module, and the second workbook doesn’t have that code. Copy the module to the second workbook via the VBA editor (drag the module from Project Explorer to the other project). Also, the second workbook might be saved as .xlsx, which discards VBA code. Save it as .xlsm.

How do I enable macros permanently for all files? Go to File > Options > Trust Center > Trust Center Settings > Macro Settings, select “Enable all macros,” and uncheck “Trust access to the VBA project object model” if you don’t need it. This is a security risk for untrusted files, so only do this on your own machine for files you trust.

Why does the macro run but my data doesn’t change? Check if the macro is targeting the wrong worksheet. Use explicit references like ThisWorkbook.Sheets("Sheet1"). Also, ensure calculation is set to Automatic (Formulas > Calculation Options > Automatic). If you’re using ActiveCell, it refers to the selected cell, which might not be where you expect.

Can I run a macro from a button if macros are disabled? No. Buttons trigger macros, but if macros are disabled, clicking the button does nothing. You must enable macros first. Also, if the button is an ActiveX control, you might need to enable “Design Mode” to edit it, but running requires macros enabled.

What does ‘Macros have been disabled’ error mean? This appears when you open a file with macros and choose not to enable them. Close the file, reopen it, and click “Enable Content” on the yellow bar. If the bar doesn’t appear, go to File > Info > Enable Content > Enable All Content.

Why does my macro work on Windows but not on Mac? VBA is slightly different on Mac: some Windows API calls won’t work, and file paths use different separators. Also, Mac Excel doesn’t support ActiveX controls (only Form controls). Check for any Application.FileDialog or SendKeys that behave differently. Test the macro on a Mac and adjust accordingly.

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.