How to Remove Macros from Excel

Macros are handy for automating repetitive work in Excel, but there are good reasons to get rid of them. Maybe you inherited a workbook full of old code, you’re sharing a file with someone who keeps getting security warnings, or you simply don’t trust where the macros came from. Whatever the reason, Excel gives you several ways to remove them.

This guide covers deleting a single macro, removing every macro at once by saving as a macro-free file, cleaning out VBA modules, and the less obvious places macros hide, like your Personal Macro Workbook.

Before You Start

  • Make a backup. Deleting a macro can’t be undone with Ctrl + Z. Save a copy of the workbook first in case you need the code later.
  • Know the file type. Workbooks that contain macros are usually saved as .xlsm (macro-enabled), .xlsb (binary) or the older .xls format. Regular .xlsx files can’t store VBA macros at all.
  • Enable editing. If the file opened in Protected View, click Enable Editing first. You don’t need to enable the macros themselves to delete them.

Method 1: Delete a Macro from the Macro Dialog Box

This is the quickest way to remove one or two specific macros.

  1. Open the workbook that contains the macro.
  2. Press Alt + F8, or go to View > Macros > View Macros. You can also use Developer > Macros.
  3. In the Macros in drop-down, choose This Workbook or All Open Workbooks.
  4. Select the macro you want to remove.
  5. Click Delete, then click Yes to confirm.

Repeat for any other macros, then save the workbook. If the Delete button is greyed out, see the troubleshooting section below.

Method 2: Remove All Macros by Saving as .xlsx

If you want every macro gone and don’t need to keep any code, this is the cleanest option. The standard Excel Workbook format simply can’t hold VBA, so Excel strips it out when you save.

  1. Go to File > Save As and choose a location.
  2. In the Save as type drop-down, choose Excel Workbook (*.xlsx).
  3. Click Save.
  4. When Excel warns that the VB project can’t be saved in a macro-free workbook, click Yes to continue.

Close the file and reopen the new .xlsx copy to confirm the macros are gone. The original .xlsm file is untouched, which gives you a built-in backup.

Method 3: Remove Modules in the Visual Basic Editor

The Macro dialog only lists public macros. Private procedures, functions and event code (macros that run automatically when you open the file or change a cell) live in the Visual Basic Editor, so this method is more thorough.

  1. Press Alt + F11 to open the Visual Basic Editor, or click Developer > Visual Basic.
  2. In the Project Explorer pane on the left (press Ctrl + R if you don’t see it), expand the project for your workbook.
  3. Open the Modules folder, right-click a module such as Module1 and choose Remove Module1.
  4. When asked whether to export the module first, click No (or Yes if you want a .bas backup file).
  5. Double-click each sheet and ThisWorkbook under Microsoft Excel Objects. If any code appears in the window, select it with Ctrl + A and press Delete.
  6. Check the Forms and Class Modules folders too, and remove any you don’t need.
  7. Close the editor and save the workbook.

Sheet and ThisWorkbook modules can’t be removed, only emptied, because they belong to the workbook itself. Microsoft explains how the editor is laid out in its guide to editing a macro.

Method 4: Delete Macros from the Personal Macro Workbook

Macros you record with Store macro in: Personal Macro Workbook are saved in a hidden file called PERSONAL.XLSB that opens every time Excel starts. To delete them:

  1. Go to View > Unhide, select PERSONAL and click OK.
  2. Press Alt + F8, select the macro and click Delete.
  3. Go back to View > Hide while PERSONAL.XLSB is the active window.
  4. Close Excel and click Save when asked about the Personal Macro Workbook.

To remove all personal macros, close Excel and delete PERSONAL.XLSB from the XLSTART folder. On Windows it’s usually in %appdata%\Microsoft\Excel\XLSTART.

Method 5: Delete Old Excel 4.0 Macro Sheets

Very old workbooks, and some malicious ones, use Excel 4.0 (XLM) macros. These aren’t stored in the Visual Basic Editor. They live on special worksheets, often named Macro1, that can be hidden or even set to “very hidden”.

  1. Right-click any sheet tab and choose Unhide. If a macro sheet is listed, select it and click OK.
  2. Right-click the macro sheet’s tab and choose Delete, then confirm.
  3. If nothing appears but you still get a macro warning, open the Visual Basic Editor, select the sheet in the Project Explorer, and in the Properties window (F4) change Visible from 2 – xlSheetVeryHidden to -1 – xlSheetVisible. Then delete it as above.

Remove Macros in Excel for Mac

On a Mac, go to Tools > Macro > Macros (or Developer > Macros), select the macro and click the minus (–) button to delete it. Saving as Excel Workbook (.xlsx) through File > Save As also removes all macros, just like on Windows.

How to Show the Developer Tab

Several of these steps use the Developer tab, which is hidden by default. On Windows, go to File > Options > Customize Ribbon, check Developer in the right-hand list and click OK. On a Mac, go to Excel > Settings > Ribbon & Toolbar and check Developer.

Troubleshooting

  • The Delete button is greyed out. The macro is in a hidden workbook, usually PERSONAL.XLSB. Unhide it first with View > Unhide.
  • The VBA project asks for a password. The code is locked. You need the password to remove modules, but you can still save the file as .xlsx to strip everything out.
  • You still see a macro warning after deleting everything. Empty modules can trigger the warning. Remove the modules entirely, or save as .xlsx. Also check for hidden Excel 4.0 macro sheets (right-click a sheet tab, choose Unhide, and delete any sheet named like Macro1).
  • The macro list is empty but code still runs. The code is probably event code in a sheet or ThisWorkbook module, or it’s in an add-in. Check File > Options > Add-ins.
  • Buttons on the sheet still exist. Deleting a macro doesn’t delete shapes or buttons assigned to it. Right-click each button and delete it, or the button will show an error when clicked.
  • You can’t save the file. The workbook may be read-only or shared. Use File > Save As to save a new copy.

Tips

  • If you only want to stop macros from running, you don’t need to delete them. Open the file without enabling content, and the code stays disabled.
  • Export modules you might need later by right-clicking them in the Project Explorer and choosing Export File.
  • Be cautious with macro-enabled files from email or the internet. Deleting unknown macros before enabling content is a safe habit.
  • When you’re ready to use macros again, see how to run macros in Excel and how to enable macros in Excel for Microsoft 365.

Frequently Asked Questions

Does deleting a macro delete my data?

No. Removing a macro only deletes the code. Your cells, formulas, charts and formatting stay as they are, although any changes the macro already made remain.

Can I undo deleting a macro?

Not with Ctrl + Z. If you haven’t saved yet, close the workbook without saving to get the macros back. Otherwise, restore from a backup or a previous version in OneDrive.

Why does my .xlsx file not have macros anymore?

The .xlsx format can’t store VBA code. If you saved a macro workbook as .xlsx, Excel removed the macros. Save as Excel Macro-Enabled Workbook (*.xlsm) to keep them.

Do I need admin rights to remove macros?

No. Anyone who can edit and save the workbook can delete its macros, unless the VBA project is password-protected or your organization manages macro settings.

How do I remove macros from many files at once?

Open each file and save it as .xlsx, or use a small VBA routine in a separate workbook to loop through a folder and save copies in .xlsx format.

Wrapping Up

To remove one macro, use Alt + F8 and click Delete. To remove them all, save the workbook as .xlsx. For a thorough cleanup, check the Visual Basic Editor and your Personal Macro Workbook. Keep a backup before you start, and you can always bring the code back if you need it.

Get Our Free Newsletter

How-to guides and tech deals

You may opt out at any time.
Read our Privacy Policy