Delete an Excel Macro: Safe Steps for Windows and Mac

VBA & macros · Updated November 20, 2026

To delete an Excel macro in Microsoft 365 for Windows, open the workbook, choose Developer > Macros, select the macro, and click Delete. If the macro is part of a VBA module, an event procedure, or your Personal Macro Workbook, use the Visual Basic Editor instead. Save a separate copy first: removing VBA cannot be undone with Ctrl+Z.

Deleting a macro removes its VBA instructions, not necessarily the button or shape that runs it. The steps below explain how to identify where the code is stored, remove only what you intend, and check that the workbook still works afterward. Excel for the web can open macro-enabled files, but it cannot edit or run VBA; use the desktop app to remove macros.

What You’ll Need

  • A desktop version of Excel that can edit VBA, such as Excel for Microsoft 365 on Windows or Mac.
  • Access to the workbook. If it is stored in OneDrive or SharePoint, make sure you can save changes or create a copy.
  • A backup copy of the workbook, especially if it contains other macros, buttons, or automated tasks.
  • If the Developer tab is not visible, you may need to turn it on in Excel’s ribbon settings.

Step-by-Step

  1. Make a backup before editing. In Excel, use File > Save As to create a copy with a different name, or duplicate the file in its folder. Keep the original unchanged until you have confirmed that the edited copy behaves as expected. A workbook may depend on macros for importing data, formatting sheets, or running a report, so a backup gives you a way to restore the original code.
  2. Open the workbook in desktop Excel and check its file type. A workbook that contains VBA is commonly saved as an Excel Macro-Enabled Workbook (.xlsm) or an older Excel Macro-Enabled Workbook (.xls). If you are working in Excel for the web, choose to open the file in the desktop app. Do not convert it to .xlsx yet as a shortcut: saving in that format removes VBA from the file, including other macros you may want to keep.
  3. Show the Developer tab if it is missing. On Windows, go to File > Options > Customize Ribbon, select the Developer check box in the main tabs list, and click OK. On Mac, open Excel > Settings (or Preferences, depending on the release) > Ribbon & Toolbar and enable Developer. The tab is only a collection of tools; showing it does not enable or run macros.
  4. Look for the macro in the Macros dialog. On Windows, choose Developer > Macros. You can also press Alt+F8. In the dialog, check the Macros in list and choose the current workbook if it is not already selected. The list may also show macros in other open workbooks or the Personal Macro Workbook. On Mac, choose Tools > Macro > Macros, or use the Macros command on the Developer tab if it is available in your ribbon layout.
  5. Select the exact macro and delete it if it is listed. Click the macro name once and read it carefully before choosing Delete. Confirm the prompt if Excel asks. The dialog is useful for ordinary, named procedures stored in a standard module. It may not show an event procedure that runs when a sheet or workbook opens, and a macro stored in a protected project or add-in may not be editable here. If Delete is unavailable, do not remove a different macro as a workaround; locate the code in the Visual Basic Editor.
  6. Open the Visual Basic Editor to inspect where code lives. On Windows, press Alt+F11 or choose Developer > Visual Basic. On Mac, use Developer > Visual Basic; the keyboard shortcut can depend on the keyboard and function-key settings, and may require Option+F11 or Fn+Option+F11. In the editor, show Project Explorer if needed with View > Project Explorer. Look for the project whose name matches the workbook, then expand its folders. You may see Microsoft Excel Objects, Modules, and possibly Forms.
  7. Remove only the intended procedure or module. For one ordinary macro, open the relevant item under Modules, find the procedure beginning with Sub and its matching End Sub, and remove that procedure’s code. Check that you have not selected neighboring procedures or declarations the other code uses. If the entire module is dedicated to the unwanted macro, right-click the module in Project Explorer and choose Remove [module name]. Excel may ask whether to export the module before removal; export it if you want an extra recoverable copy. Removing a module deletes every procedure and other code in that module, not just the macro you first noticed.
  8. Check event code and the Personal Macro Workbook if necessary. A macro that runs automatically may be inside a worksheet object or ThisWorkbook, rather than under Modules. In Project Explorer, open the relevant sheet or ThisWorkbook and look for procedures such as Worksheet_Change or Workbook_Open. Remove only the unwanted event procedure, preserving other event code. If the macro belongs to PERSONAL.XLSB, expand that separate project and edit its code there; changes to it affect macros available in other workbooks too.
  9. Save, close, and verify the edited copy. Return to Excel and save the workbook. Keep it as .xlsm if other VBA must remain. Close and reopen the copy, then check the Macros dialog or the feature that used to run the macro. If it was assigned to a button, shape, or form control, the control may remain visible even though its code is gone. Remove or reassign that control separately if it is no longer needed. Keep the backup until you are satisfied that unrelated workbook functions still work.

Common Mistakes

Deleting a whole module to remove one macro. A module can contain several procedures, helper routines, and declarations. Before removing it, open it and inspect all the code. If you only need to remove one macro, delete just that procedure and preserve shared code. If it is unclear what a procedure supports, leave the backup untouched and ask the workbook’s owner before making a broad change.

Confusing the macro with its button. A button or shape is an object on a worksheet; the macro is code stored elsewhere. Deleting one does not automatically delete the other. A leftover button can display an error when clicked because its assigned procedure no longer exists. Conversely, deleting a button does not remove the macro, which could still appear in the Macros dialog or be called by another procedure.

Saving as .xlsx without checking what else is in the file. This format does not store VBA. Excel warns that some features cannot be saved, but accepting the change removes VBA from the saved file, not just the one macro you meant to delete. Use the VBA Editor for selective removal. Choose .xlsx only when you intentionally want a macro-free copy and have confirmed that losing all VBA is acceptable.

Editing the wrong open workbook. The Macros dialog can list macros from several open files, and the Personal Macro Workbook may be loaded in the background. Confirm the workbook or project name before deleting code. A macro with a familiar name in another project may serve a different purpose.

Expecting Ctrl+Z to restore VBA. Excel’s normal Undo command does not reverse code deletion in the Visual Basic Editor. That is why making a separate copy or exporting a module matters. Do not rely on the Undo history as a backup.

Tips

Use the Macros dialog first when you know the exact name of a regular macro. It is quick and reduces the chance of changing unrelated code. Use the Visual Basic Editor when the macro is not listed, when you need to inspect its contents, or when it is an event procedure. If you are unsure where code is stored, search the workbook’s project in the editor rather than deleting items by guesswork.

Before removing a procedure, consider whether another macro calls it. A helper procedure might not appear as something you run directly, yet other code may rely on it. If deleting it causes a compile error or breaks an automation flow, restore the backup and investigate the references first. Also check whether the workbook owner expects a macro to run when opening the file or changing cells.

If the goal is to stop a macro from running rather than remove it permanently, a backup is still important. Removing or changing an event procedure is different from changing macro security settings, and security settings can affect more than one workbook. Avoid enabling all macros just to inspect code. If the file came from an untrusted source, do not run its macros; ask the sender for a safe, macro-free version when possible.

Keep a note of what you removed and from which workbook copy. This is useful when a workbook is shared or when a button or automated task later needs to be repaired. For collaborative files, tell other users that the macro was removed and whether its associated button remains. On Mac, the same general approach applies, although ribbon labels and shortcut behavior can vary slightly by Excel release.

Troubleshooting

The macro is not in the Macros list. Confirm that the correct workbook is selected in the Macros in list and that the relevant file is open. Check whether the code is in PERSONAL.XLSB, an add-in, a worksheet object, or ThisWorkbook. Event procedures are not necessarily listed as ordinary macros. Open the VBA Editor and inspect the workbook project instead.

The Delete button is unavailable, or Excel will not let you edit the code. The selected item may be in a protected VBA project, an add-in, or a workbook you can view but not modify. If the workbook structure or project is password-protected, you need authorization and the password from its owner; do not try to bypass protection. For an add-in, contact its publisher or work from an authorized, editable copy. Also check that the workbook itself is not read-only and that you have permission to save changes.

The macro still runs after you delete it. It may exist in another open workbook or in PERSONAL.XLSB, or a different procedure may perform the same task. Reopen the Macros dialog and check its workbook scope. Look at any buttons, shapes, or controls to see which macro they are assigned to. If it is an automatic action, inspect the relevant sheet and ThisWorkbook event code.

A button now gives an error. The button may still be assigned to the deleted macro. If you no longer need the button, remove the object from the sheet. If you need it, right-click the button or shape, choose Assign Macro, and select an existing replacement. On Mac, the context-menu wording or control options can differ by object type. If the assignment cannot be changed or the button is a form control, check the workbook owner’s instructions before removing it.

The workbook will not save as macro-enabled, or a warning appears. Use File > Save As and select Excel Macro-Enabled Workbook (.xlsm) if VBA remains. If you intentionally want a macro-free file, save a separate .xlsx copy and read Excel’s warning before confirming. If you see a permission or read-only message, save a copy to a folder where you have write access.

Frequently Asked Questions

Can I delete one macro without deleting all the macros?
Yes. Select that procedure in Developer > Macros and use Delete, or remove only its code in the VBA Editor. Avoid removing the whole module unless you have checked that it contains no other code you need.

Does deleting a macro delete its worksheet button?
No. The button or shape is a separate worksheet object. It can remain on the sheet and may show an error when clicked if it still points to the deleted macro. Remove the object or assign it to a valid macro separately.

Can I delete a macro in Excel for the web?
No. Excel for the web does not provide the VBA Editor for removing macro code. Open the workbook in desktop Excel for Windows or Mac, make a backup, and use the Macros dialog or VBA Editor.

Will saving as an XLSX file remove just one macro?
No. An .xlsx file cannot contain VBA, so saving in that format removes the workbook’s VBA rather than selectively deleting one procedure. Use the VBA Editor for selective removal and keep the file as .xlsm if other macros remain.

Can I recover a macro after deleting it?
Excel’s Undo command does not restore deleted VBA. Reopen the untouched backup, or import a module you exported before removing it. If neither is available, check your organization’s file history or backup service for an earlier copy.

Does deleting a macro change other workbooks?
It depends where the code is stored. Removing a macro from the current workbook affects that workbook; editing PERSONAL.XLSB changes the personal macros available across Excel workbooks on that computer. Confirm the project name before editing and save a backup of the Personal Macro Workbook as well.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.