If a macro will not run in Excel, first check that you opened the file in the desktop app, that it is saved as a macro-enabled workbook, and that Excel has not blocked its macros. Then use Developer > Macros to select and run it; if it is missing or produces an error, the file format, security settings, or VBA code may be the cause.
Start with the quickest checks
Before changing security settings or editing code, confirm what “not working” means. A macro may be unavailable in the list, disabled by Excel, stopped by an error, or completed without an obvious visible result. Those symptoms point to different causes, so note any warning banner, error number, or message before troubleshooting further.
Try these checks in order:
- Open the workbook in the Excel desktop app for Windows or Mac, not Excel for the web.
- Look at the filename extension. A workbook containing VBA generally needs to be saved as .xlsm or .xlsb.
- Check for a yellow security warning or a message that macros have been blocked.
- Choose Developer > Macros, select the macro, and click Run. On Windows, Alt+F8 also opens the Macro dialog.
- If Excel shows an error, record its wording and where the code stops before making changes.
If the workbook came from email, a chat, or a website, do not enable its macros simply to see what happens. A macro can change files, send data, or perform other actions on your computer. Only proceed when you trust the file and its source.
Check the workbook format
The standard .xlsx format does not store VBA macros. If a macro-enabled workbook is saved as .xlsx, Excel warns that some features cannot be saved; choosing to continue without preserving the VBA can remove the macros from the saved copy. The original file may still contain them, so check whether you are opening the correct version.
For a workbook that needs to retain macros, use File > Save As, then choose Excel Macro-Enabled Workbook (*.xlsm). Excel Binary Workbook (*.xlsb) can also contain VBA. The older .xls format supports macros too, but it is a legacy format and may have compatibility limitations. Do not rename an .xlsx file to .xlsm: changing the letters in the filename does not restore VBA that was not saved in the workbook.
To confirm the format in Windows, look at the filename in File Explorer or choose File > Info in Excel. If you need to preserve the original while testing, save a separate .xlsm copy. If the macro is supposed to be in a personal macro workbook or an add-in, the code may not be stored in the workbook you are currently viewing; check the Macro dialog’s “Macros in” list.
Review Excel’s macro security settings
Excel may block macros by design. On Windows, open File > Options > Trust Center > Trust Center Settings > Macro Settings to review the available choices. “Disable VBA macros with notification” allows Excel to show a warning for files whose macros are disabled. Setting macros to run without notification or enabling all macros broadly lowers protection and is not a good general fix.
When a file is trusted and Excel presents an Enable Content button, you can choose it for that workbook after checking its source. If the file was downloaded from the internet, Windows or Office may block its macros even when you change a general macro setting. In Windows File Explorer, right-click the file, choose Properties, and look on the General tab for an Unblock checkbox or button. This option is not shown for every file or in every configuration. Unblock only a file you have verified and intend to trust.
In a workplace or school, an administrator may control these settings through organizational policy. If settings are unavailable or keep reverting, contact the organization’s IT support rather than trying to bypass the policy. A trusted location can be appropriate for files you control, but it should be a carefully managed folder—not a broad location such as Downloads where unknown files accumulate.
Run the macro from the right place
In desktop Excel, enable the Developer tab if it is hidden: choose File > Options > Customize Ribbon, select Developer in the Main Tabs list, and click OK. Then choose Developer > Macros, select the macro name, and click Run. This is a useful test because it separates a macro-launch problem from a button or keyboard shortcut that may be misconfigured.
The Macro dialog usually lists public procedures with no arguments that are in standard modules. A procedure placed in a worksheet’s code module, marked Private, or written to require input may not appear there in the same way. A macro assigned to a worksheet button can also stop working if the button was copied from another workbook, its assignment was removed, or the workbook’s structure has changed. Try the Macro dialog first, then inspect the button’s assignment if the macro works there.
On Mac, use the Developer tab and its Macros command; ribbon labels and preferences can differ slightly by Excel release. Alt+F8 is the Windows shortcut and does not apply to Mac. Excel for the web can display and edit many workbook contents, but it cannot run VBA macros. Choose Open in Desktop App to run a VBA macro.
Diagnose VBA errors and macros that do nothing
If a macro appears in the list but fails, the exact error is important. For example, “Subscript out of range” can mean the code refers to a worksheet or workbook name that does not exist. A “Type mismatch” often points to a value being used in an unexpected form. These examples are clues, not definitive diagnoses: read the highlighted line and check the actual workbook names, cell values, and objects the code expects.
Open the Visual Basic Editor with Developer > Visual Basic. If the error highlights a line, inspect its references and use the editor’s Debug options to step through the code or check variable values. A compile error may be found using Debug > Compile VBAProject in the Visual Basic Editor. The exact menus can vary slightly with the editor version. If you are not the author, avoid changing unfamiliar code; ask the author what inputs and workbook layout it expects.
If the macro finishes but nothing seems to happen, check whether it is looking at the active workbook, a particular sheet, a named range, or a specific folder. A changed sheet name, selection, or file path can leave a macro acting on the wrong object or skipping its intended work. Check whether the macro is designed to show a message, write results to cells, or update another workbook. Also consider whether an earlier routine turned off application events or screen updating and failed to restore them; that can make later actions appear unresponsive.
A small, harmless test can distinguish a general run problem from a problem in the original procedure. In a copy of a trusted macro-enabled workbook, insert a standard module in the Visual Basic Editor and try this example:
Sub TestMacro()
' Confirm that a simple VBA procedure can run.
Dim message As String
message = "The test macro ran."
MsgBox message
End Sub
Save a copy of the workbook before running any macro. VBA actions cannot be undone with Ctrl+Z, including changes made by a test macro. If this test runs but the original procedure does not, Excel can run VBA and the problem is more likely specific to the original macro, its inputs, or its workbook references. Remove the test code when finished if it is not needed.
Excel for the web, Mac, and shared workbooks
Excel for the web is a common source of confusion: opening an .xlsm file in a browser does not mean its VBA can run there. The workbook may still be viewable, and some non-VBA features may work, but running a VBA macro requires desktop Excel. If a workbook is stored in OneDrive or SharePoint, open it in the desktop app and make sure you are signed in with access to the file.
Mac Excel supports VBA, but the ribbon, security preferences, keyboard shortcuts, and some Windows-specific code behavior differ. A macro that relies on Windows-only components, file paths such as a drive letter, or an external program may need changes to work on Mac. When a workbook is shared between platforms, ask whether the macro was written for Windows, Mac, or both. Do not assume that a Windows error proves the workbook is damaged.
Coauthoring and file permissions can also matter. If the workbook is read-only, opened from a restricted location, or being edited by another person, a macro may be unable to save changes where expected. Check that you have permission to edit the file and that the destination folder is available. Save a working copy locally only if your organization’s rules permit it.
Use safe troubleshooting practices
Macros run with the permissions available to Excel, so an untrusted macro is not just a spreadsheet calculation. It may alter workbook data, access files, or interact with other resources. A request to enable macros in an unexpected invoice, résumé, or shared document is a warning sign, not a routine instruction.
- Verify the sender and obtain the workbook through a known, trusted channel.
- Keep an untouched backup and test on a separate copy, especially if the macro edits or deletes data.
- Ask the author what the macro is intended to do and which workbook version or sheet names it expects.
- Do not set Excel to enable all macros globally just to make one file run.
- If a file is suspicious or your organization blocks it, stop and contact IT or the person responsible for the workbook.
These precautions also make ordinary troubleshooting easier. If the macro changes the wrong cells, a backup offers a recovery route; if it behaves differently on a copy with known sheet names, that helps identify a dependency rather than a general Excel failure.
Frequently Asked Questions
Why is my macro missing from the Excel Macro list?
Confirm that the file contains VBA and is saved as .xlsm or .xlsb. The Macro dialog generally lists public procedures without arguments in standard modules. Code in a worksheet module, a private procedure, an add-in, or a personal macro workbook may need to be accessed differently; check the “Macros in” selection and ask the code’s author where it is stored.
Can I run a macro in Excel for the web?
No. Excel for the web does not run VBA macros. Open the workbook in the Excel desktop app for Windows or Mac to run its VBA, provided the file and its macros are trusted and permitted by your security settings.
Why does Excel say macros have been blocked?
Excel may have disabled the VBA because of its security settings, or Windows and Office may treat a downloaded file as coming from the internet. Verify the workbook’s source first. If you trust it, review the warning and applicable settings; for a downloaded file, check Properties for an Unblock option. Managed work devices may enforce a policy that only an administrator can change.
Will saving an .xlsm file as .xlsx keep the macro?
No. The .xlsx format does not retain VBA code. Save as .xlsm or .xlsb when the workbook needs its macros. If you already saved an .xlsx copy, look for the original macro-enabled file or a backup; changing the extension of the .xlsx copy cannot bring deleted VBA back.
Why does a macro run but make no visible change?
The code may rely on a particular active workbook, sheet name, selection, input value, or file path, or it may work without displaying a message. Check the macro’s expected inputs and output locations, then step through its code in the Visual Basic Editor if appropriate. Test only with a backup because macro changes cannot be reversed with Ctrl+Z.
Related
- Password Protect an Excel Document From Opening
- Password Protect an Excel Document to Open
- Password Protect Excel Before Opening: How It Works
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Dictionary Methods: Add, Exists, Keys and MoreA VBA Dictionary stores pairs of unique keys and associated values, and its core methods are Add, Exists,…
- 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…
- Excel VBA Zoom: Set and Manage Worksheet MagnificationTo change the zoom of the active Excel worksheet with VBA, set ActiveWindow.Zoom to a percentage from 10…
- Excel VBA Text Color: Change Font and Cell Colors EasilyTo change text color in Excel VBA, set a range’s Font.Color property, usually with RGB(red, green, blue). For…
- VBA Dictionary Remove Key: Safe Removal and Common ErrorsTo remove one entry from a VBA Dictionary, call its Remove method with the key: dict.Remove key. If…
- Excel VBA Application-Defined or Object-Defined ErrorIn Excel VBA, “Application-defined or object-defined error” is usually runtime error 1004: Excel could not complete an operation…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.