VBA & Macro Problems

How to Remove Macros and VBA Code from an Excel Workbook

Ayan MasoodAyan Masood Nov 3, 2026 869 views

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.

How to Remove Macros and VBA Code from an Excel Workbook
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Workbook

Launch Excel and open the workbook containing the macros you want to remove.

2
Navigate to Save As

Click the 'File' tab in the top-left corner and select 'Save As' from the left-hand menu.

3
Select XLSX Format

Choose your save location. In the 'Save as type' or 'File Format' dropdown menu, select 'Excel Workbook (*.xlsx)'.

4
Confirm Macro Removal

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.

Save the Workbook in XLSX Format
Complete Removal: This method perfectly scrubs the document of all executable code, ensuring the resulting file is 100% macro-free and safe to share.
Manage Macros Easily

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. 1. Open File in WPS Spreadsheet: Launch WPS Office and open your macro-enabled document.
  2. 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. 3. Open Save As Dialog: To remove all code at once, click 'Menu' in the top-left corner and select 'Save As'.
  4. 4. Choose XLSX Format: Select 'Microsoft Excel Workbook (*.xlsx)' from the file type dropdown menu.
  5. 5. Save and Clean: Click 'Save' and confirm the prompt to strip all VBA projects, successfully generating a secure, macro-free document.
Seamlessly compatible with Microsoft Excel formats (.xlsx, .xlsm, .xls)Built-in VBA and Macro support for editing or removing complex automationFree, lightweight, and easy-to-use Office alternativeQuickly convert macro-enabled workbooks to safe, macro-free files
microsoft office alternative - wps office

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.