How to Remove Macros from Excel Safely and Completely
In this article
macros in Excel are small programs written in Visual Basic for Applications (VBA) that automate tasks. Removing them eliminates automation code, which improves security (especially when opening files from untrusted sources), reduces file size, and ensures files open without triggering macro security prompts. You’ll need the Excel file containing the macros, and it must be saved in a format that supports macros (like .xlsm) before removal—otherwise, macros won’t exist in the file to begin with.
What You'll Need
- The Excel workbook (.xlsx, .xlsm, or .xls) containing the macros
- Excel installed (Excel 2010 or newer; steps apply to Microsoft 365, Excel 2016–2021, and Excel for Microsoft 365 on Windows/macOS)
- File saved locally (not only in cloud storage during active sync—save locally first to avoid errors)
Step-by-Step
- Open the Excel file containing the macros.
- Press Alt + F11 (Windows) or Fn + Option + F11 (older Mac) to open the Visual Basic for Applications (VBA) editor. On newer Macs with a function row, press Fn + Option + F11; if that doesn’t work, try Cmd + Option + F11 or go to Excel > Preferences > Ribbon & Toolbar > check "Developer" to enable the Developer tab first.
- In the VBA editor, locate the Project Explorer window on the left. If it’s not visible, press Ctrl + R (Windows) or Cmd + R (Mac) to show it.
- Expand each project folder (e.g., VBAProject (YourFileName.xlsx)) to see all components: ThisWorkbook, sheets (Sheet1, Sheet2, etc.), and any Modules or Class Modules.
- Right-click each module, class module, or ThisWorkbook object, then select Remove [Component Name]. If prompted to export the component first, click No—you’re deleting, not saving a backup.
- After removing all modules and code objects, check for hidden or very hidden sheets that may contain macro-dependent code. In Excel (not the VBA editor), right-click any sheet tab > Unhide, and delete any suspicious or unnecessary sheets. Very hidden sheets (visible only in VBA) should be deleted in the VBA editor by right-clicking the sheet name and selecting Remove [SheetName].
- Return to Excel. Go to the Developer tab (if hidden, enable it via File > Options > Customize Ribbon > check “Developer”). Click Macros in the Code group. Ensure the macro list is empty—if any macros remain listed, select each and click Delete.
- Save the workbook. Press Ctrl + S (Windows) or Cmd + S (Mac). If the file is currently saved as .xlsx, Excel will keep it as .xlsx (no macros supported). If it’s .xlsm, Excel will strip macros but keep the .xlsm extension—consider saving as .xlsx to prevent accidental re-addition of macros later.
- Close and reopen the file to confirm macros no longer run. When opened, Excel should not display a security warning about macros, and no automated behavior (like auto-open forms or sheet changes) should occur.
Common Mistakes
- Skipping the Developer tab step: some users try to delete macros via File > Info > Edit Links or Properties, but those options don’t remove VBA code—only the VBA editor or Macro dialog does.
- Leaving hidden sheets in place: very hidden sheets can contain event-driven macros (e.g., Worksheet_Activate) that trigger automatically; always check the VBA editor for these.
- Forgetting to delete macros from the Personal Macro Workbook: if macros were recorded to “Personal Macro Workbook,” they persist across files. To remove them, open the Personal Macro Workbook (File > Open > Personal Macro Workbook), then delete modules as above.
- Assuming saving as .xlsx automatically removes macros: it does not if macros are embedded in the workbook itself. Saving as .xlsx only prevents *future* macro addition; existing VBA code must be explicitly deleted.
- Not restarting Excel after deletion: sometimes, cached references linger. Fully close Excel (not just the window) and reopen to test.
Tips
- Before removing macros, create a backup copy of the file (File > Save As > name it “FileName_backup.xlsm”) in case you need to recover logic later.
- Use the Macro Security settings (File > Options > Trust Center > Trust Center Settings > Macro Settings) to set “Disable all macros with notification” while working—prevents accidental execution during cleanup.
- To verify all code is gone, press Alt + F11 again and confirm the Project Explorer shows only standard workbook elements (e.g., “Excel Objects” like Sheet1, ThisWorkbook—but no Modules or ClassModules).
- On macOS, ensure you’re using Excel 2016 or later; older versions (like Excel 2011) have limited VBA support and may behave differently.
- For files with many macros, use the “Export” feature before removal: right-click a module, choose Export File, save it elsewhere, then remove. This lets you review code later if needed.
- After removal, run File > Info > Check for Issues > Inspect Document to scan for remaining macros or hidden data.
Troubleshooting
If macros still appear or run after following the steps:
- Check the Personal Macro Workbook: Open Excel > File > Open > Personal Macro Workbook. If it opens, delete all modules as in Step 5 above, then close and restart Excel.
- Look for add-ins: Go to File > Options > Add-ins. At the bottom, select “Excel Add-ins” in Manage, click Go, and uncheck or remove any suspicious add-ins (e.g., “Analysis ToolPak” isn’t a concern, but unknown third-party tools may contain macros).
- Inspect embedded objects: Some macros are triggered by ActiveX controls or form controls. In Excel, go to Developer > Insert, and delete any buttons, list boxes, or checkboxes that reference macros.
- Recover from a corrupted VBA project: In the VBA editor, go to Tools > VBAProject Properties > General tab. Ensure “Unlock project for viewing” is unchecked (if locked, you cannot edit or delete). If locked, you’ll need the password—contact the file’s creator.
- Use a clean import: Copy all content (Ctrl+A, Ctrl+C) from the original sheet, paste into a *new* Excel workbook (File > New > Blank Workbook), then save the new file. This often strips embedded code without the VBA editor.
Frequently Asked Questions
Do I need to save the file as .xlsx to remove macros?
No—macros are removed by deleting VBA code in the editor. Saving as .xlsx prevents future macro use but doesn’t delete existing code. You can delete macros in an .xlsm file and keep the format.
Will removing macros delete my data or formulas?
No. Macros are separate code modules. Removing them only deletes automation logic; cell data, formulas, formats, and charts remain intact.
How do I know if a file actually contains macros?
Open the file, press Alt + F11. If the Project Explorer shows Modules or ClassModules, macros exist. Alternatively, go to Developer > Macros—if the list isn’t grayed out and shows entries, macros are present.
Can I remove macros from a shared or network file?
Yes—if you have edit permissions. Save the file locally first (to avoid sync conflicts), remove macros, then save back to the network location. Ensure no one else has it open during the process.
Why does Excel still prompt to enable macros after deletion?
This usually means the macro security setting is set to “Enable all macros” or the file is digital-signed. Reset security to “Disable all macros with notification” (File > Options > Trust Center), and check File > Info > Protect Workbook for digital signatures.
Is there a way to bulk-remove macros from many files at once?
Excel doesn’t support this natively. You’d need a VBA script to loop through files—but that defeats the purpose. Use third-party tools like KBM Macro Cleaner (commercial) or write a PowerShell script (advanced users only).