How to Remove Macros and VBA Code from an Excel Workbook
Question details
The user needs a reliable method to remove specific macros, VBA modules, and embedded code from an Excel workbook, or strip the file entirely of macro content.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Cleaning up an Excel workbook to remove potentially unsafe or unnecessary VBA code and macros before sharing or finalizing the document.
- Observed behavior
- Individual macros can be deleted via the Macros dialog, but hidden VBA modules and embedded elements might persist unless completely cleared or the file is saved in a macro-free format.
Verify if other team members rely on the macros before deleting them, and save a duplicate of the original macro-enabled file (.xlsm) so you do not permanently lose essential automation scripts.
Save the Workbook in XLSX Format
The fastest and most thorough way to strip all macros and VBA code from an Excel file is to save it as a standard macro-free .xlsx workbook.
Because the standard .xlsx file format fundamentally does not support Visual Basic for Applications (VBA), saving your file this way acts as an automatic filter. It removes all macros, VBA modules, and form controls simultaneously without requiring you to manually hunt down hidden scripts.
Launch Excel and open the workbook containing the macros you want to remove.
Click the 'File' tab in the top-left corner and select 'Save As' from the left-hand menu.
Choose your save location. In the 'Save as type' or 'File Format' dropdown menu, select 'Excel Workbook (*.xlsx)'.
Click 'Save'. Excel will display a prompt warning you that VBA projects cannot be saved in macro-free workbooks. Click 'Yes' to proceed. All VBA code and macros will be permanently removed from this new file.

Delete Individual Macros via the View Tab
If you want to keep the file format as .xlsm but only remove specific macros, you can delete them one by one through the Macros dialog box.
Remove Remaining Modules via the Visual Basic Editor
Deleting a macro from the ribbon sometimes leaves behind empty VBA modules. Use the Visual Basic Editor to clear out these leftover components.
Easily Manage or Remove Macros with WPS Spreadsheet
WPS Office offers a fully compatible Spreadsheet tool that allows you to manage, edit, or remove VBA macros with a familiar, intuitive interface. You can effortlessly clean your macro-enabled files (.xlsm) by saving them into standard formats (.xlsx) to automatically strip out unwanted scripts.
- 1. Open File in WPS Spreadsheet: Launch WPS Office and open your macro-enabled document.
- 2. Access the Macros Tool: Go to the 'Tools' tab on the ribbon and click on 'Macros' to view or manually delete individual scripts.
- 3. Open Save As Dialog: To remove all code at once, click 'Menu' in the top-left corner and select 'Save As'.
- 4. Choose XLSX Format: Select 'Microsoft Excel Workbook (*.xlsx)' from the file type dropdown menu.
- 5. Save and Clean: Click 'Save' and confirm the prompt to strip all VBA projects, successfully generating a secure, macro-free document.

Frequently Asked Questions
Can I recover a macro after I delete it?
Once a macro is deleted and the workbook is saved, it cannot be recovered. It is highly recommended to keep a backup copy or export the VBA module before deleting.
Why does my file still have a macro warning after I deleted the macros?
You may have deleted the macro scripts but left behind empty VBA modules or form controls. To fix this, open the Visual Basic Editor (Alt + F11) and remove any remaining empty modules, or simply save the file as a macro-free .xlsx document.
What is the difference between .xlsx and .xlsm formats?
The .xlsx format is a standard Excel workbook that strictly prevents any VBA code or macros from being saved. The .xlsm format is specifically designed to allow and store macro code safely.




