Deleting an Excel macro removes its VBA procedure so it can no longer be run from that workbook. You can remove a single macro while keeping other macros, or remove all VBA by saving a copy in a macro-free format. Before changing anything, save a backup and confirm where the macro is stored. These steps apply to the desktop versions of Excel; Excel for the web does not provide the VBA editor needed to delete macros.
What You’ll Need
- The Excel workbook, personal macro workbook, or add-in that contains the macro, opened in desktop Excel.
- Permission to edit and save that file. If the VBA project is password-protected, you will need the password to edit its code.
- A backup copy, especially if the workbook contains other macros, automated tasks, or important data.
Step-by-Step
- Make a backup and identify the file you are changing. Open the workbook and use Save As to make a separate copy before editing. Give the copy a clear name so you can distinguish it from the original. If the macro runs when you open a workbook or is available in several workbooks, it may not be stored in the file currently on screen. A macro can reside in another open workbook, the Personal Macro Workbook, or an Excel add-in. Check the macro list’s workbook filter before deleting anything.
- Open the macro list. In desktop Excel for Windows, press Alt+F8. Alternatively, choose View > Macros > View Macros, or use the Macros control on the Developer tab. On a Mac, use the Macros command on the View or Developer tab; the menu location can vary by Excel version. The dialog shows macros Excel can list and run. Use the Macros in or equivalent workbook selector to look at the intended workbook rather than assuming the selected macro belongs to the active sheet or file.
- Select the macro you intend to remove. Read the displayed name carefully, then check which workbook is selected in the dialog. If more than one open file has a macro with the same name, the workbook selector matters. Do not choose a similarly named macro in PERSONAL.XLSB or an add-in unless that is the one you want to change. If you cannot find the macro here, continue to the Visual Basic Editor method below; some kinds of procedures do not appear in this list.
- Delete it from the dialog if the option is available. Select the macro and choose Delete, then confirm if Excel asks. The macro is removed from the workbook’s VBA project; it is not merely hidden from the list. If Delete is unavailable or the procedure is not listed, do not assume the macro is already gone. It may be private, have parameters, be an event procedure, or live in a location you have not selected. Use the editor method instead.
- Open the Visual Basic Editor to inspect the code. In Windows desktop Excel, press Alt+F11, or select Developer > Visual Basic. On a Mac, open the Visual Basic Editor from Excel’s Developer or Tools menus; the exact menu path and keyboard shortcut vary by version and keyboard. In the editor, show Project Explorer from the View menu if it is not visible. Find the project for the workbook you intend to edit, then expand its folders, such as Modules, Microsoft Excel Objects, and Forms.
- Remove only the intended procedure. Double-click a standard module to view its code. A macro usually starts with a line such as
Sub MacroName()and ends withEnd Sub. Select the complete procedure, including those boundary lines, and delete it. If the same module contains other procedures, leave them in place. Review the surrounding code before editing: a procedure may call another macro, and a name that looks similar may belong to a different task. - Handle code stored outside a standard module carefully. A procedure may be in a worksheet object’s code window or in ThisWorkbook, particularly if it runs in response to an event such as opening the file or changing a cell. Remove only the relevant procedure in that code window. Do not try to delete the worksheet or ThisWorkbook object itself; those objects are part of the workbook. If the code is in a form or another component, confirm what depends on it before removing the procedure or component.
- Remove a whole module only when that is what you mean. If the module contains nothing you need, right-click its name in Project Explorer and choose Remove. Excel may ask whether to export the module first. Exporting saves a separate copy of the module’s code; do this if you might need to restore it. Removing a module deletes every procedure in it, not just the macro you selected, so inspect its contents first. Do not remove a component simply because its name is unfamiliar.
- Save, close, and verify the result. Return to Excel and save the edited file. Reopen the macro list and check that the intended macro is no longer available from the workbook. If you edited a procedure that is not listed, return to the editor and confirm the code was removed. Close and reopen the backup copy or edited file if appropriate, then test the workbook’s ordinary features to make sure unrelated formulas, buttons, and macros still work.
If you want to remove every macro rather than one procedure, use Save As to create a separate .xlsx copy and accept Excel’s warning that VBA content will not be saved in that format. Keep the original macro-enabled file if you may need its code later. Saving as .xlsx is a broad removal method: it removes VBA from the saved copy, not just one selected macro, and can also affect macro-dependent features.
Common Mistakes
- Deleting the wrong copy. A macro that appears available in a workbook may actually belong to PERSONAL.XLSB or an add-in. Check the workbook selector before using Delete.
- Removing an entire module to get rid of one macro. A module can hold several procedures. Delete just the target Sub and its matching End Sub unless you have checked that the whole module is disposable.
- Confusing removal with disabling. Changing macro security settings can stop code from running, but it does not delete the code. Conversely, deleting the procedure does not necessarily remove a separate button or shape that used to launch it.
- Saving as .xlsx without keeping a macro-enabled copy. This format cannot retain VBA. Keep a backup in the original format if you may need the macros or related automation.
- Deleting an event procedure without checking its purpose. Code in a worksheet or ThisWorkbook object may run automatically. Removing it can stop an automated task that is not visible in the standard macro list.
Tips
- Save the backup before opening the editor, and make the change in the copy first. That gives you a straightforward way to recover if the wrong procedure is removed.
- Use the procedure name and its code to confirm what you are deleting. Names such as
Workbook_OpenorWorksheet_Changeindicate event-driven code, not necessarily a macro launched from the Macros dialog. - If a worksheet button or shape still appears after its macro is deleted, remove or update the control separately. In Excel, right-click a shape or form button and check its assigned macro or use the relevant object controls. A control can remain even when its assigned procedure no longer exists.
- If the VBA project is digitally signed, changing its code can invalidate its existing signature. The workbook’s owner may need to review and sign the updated project again.
- Keep the original file extension when saving a workbook that still needs other VBA macros. Macro-enabled Excel workbooks commonly use
.xlsm; a macro-enabled Excel template commonly uses.xltm.
Troubleshooting
The macro is missing from the list. In the macro dialog, change the workbook filter to check other open workbooks, including PERSONAL.XLSB. If it still does not appear, inspect the relevant VBA project in the editor. Procedures declared Private, procedures that require arguments, and event procedures commonly are not listed as ordinary runnable macros. The code may also be inside an add-in rather than the workbook.
Delete is greyed out or Excel will not let you edit. Confirm that you selected a macro that can be deleted from that dialog and that you have the correct workbook selected. Check whether the file is read-only, opened in Protected View, or restricted by editing permissions; use a trusted editable copy if you are authorized to change it. If the VBA project is locked, you need its password from the project owner. Do not try to bypass the protection.
The macro returns after you remove it. You may have edited a different copy, or the code may be stored in PERSONAL.XLSB or an add-in. Check the file path and workbook selector, then inspect the other loaded projects. If the macro is supplied by an add-in, you may need to change or remove that add-in through Excel’s add-in settings, or ask its publisher or owner for an editable source file.
A button now gives an error. The button may still be assigned to the deleted macro. Either assign it to a replacement procedure, remove the obsolete button, or restore the procedure from your backup if the button is still needed. Do not delete unrelated code to clear the error.
The workbook behaves differently after saving. Reopen the saved copy and check its extension. If you saved as .xlsx, VBA code is not retained in that copy, so macros and features depending on them will not work there. Return to your macro-enabled backup if you need the original behavior, then remove only the intended procedure and save in a macro-enabled format.
Frequently Asked Questions
Can I delete one macro without deleting the others?
Yes. Delete the selected macro from the Macros dialog when available, or remove only its complete procedure in the VBA editor. Avoid removing its whole module unless you have confirmed that no other code in that module is needed.
Does deleting a macro delete the workbook or its data?
No. Deleting a procedure removes VBA code, not worksheet cells or the workbook itself. However, a button, event, or other feature that relied on the code may stop working, so check the workbook after the change.
Can I delete a macro in Excel for the web?
Excel for the web does not include the desktop Visual Basic Editor for editing or deleting VBA procedures. Open the file in desktop Excel, make the change there, and save it. If desktop Excel is unavailable, ask someone with access to edit the workbook.
What is the difference between deleting and disabling a macro?
Deleting removes the procedure from the VBA project. Disabling or blocking macros changes whether Excel allows code to run, but leaves that code in the file. Use deletion when you want the code removed, and security settings when you want to control execution.
How do I remove all macros from a copy of a workbook?
Save a separate copy in the .xlsx format and confirm Excel’s warning about removing VBA content. The copy will not contain VBA macros, while the original macro-enabled file can remain unchanged. Check whether workbook features depend on the macros before relying on the copy.
Can I delete a macro if I do not know the VBA project password?
You cannot edit a password-protected VBA project without authorization and the required password. Ask the workbook owner or administrator for access or an editable copy. Do not attempt to bypass the project protection.