Deleting a macro in Excel means removing the recorded or written code that automates a task
A macro is a set of instructions that Excel runs automatically when you trigger it — usually by clicking a button or pressing a keyboard shortcut. If you no longer need a macro, you can delete it permanently. The process is straightforward and takes less than a minute. You cannot undo a deletion, so make sure you no longer need the macro before you remove it.
Where you delete a macro depends on how it was stored. Macros live in one of three places: the workbook you are currently using, your personal macro workbook (a hidden file Excel creates on your computer), or an add-in file. Most macros you create yourself are stored in the current workbook, which is the easiest place to delete them from.
Key Takeaways
- Open the Developer tab, click Macros, select the macro you want to remove, and click Delete — this works for macros stored in your current workbook.
- Deleting a macro from the current workbook removes it only from that file; the same macro may still exist in other workbooks or your personal macro workbook.
- If a macro is stored in your personal macro workbook, you must unhide that workbook first before you can delete the macro from it.
- Macros stored in add-in files (.xlam files) must be deleted by removing or editing the add-in file itself, not through the Macros dialog.
How to delete a macro from your current workbook
This is the most common scenario. Open the Excel file that contains the macro you want to delete. If the Developer tab is not visible on your ribbon, you need to turn it on first: go to File, then Options, then Customize Ribbon, check the Developer box, and click OK.
Once the Developer tab is visible, click it. In the Code group, click Macros. A dialog box opens showing all macros stored in the current workbook. Find the macro you want to delete in the list, click it once to select it, then click the Delete button. Excel asks you to confirm — click Yes. The macro is now gone from this workbook.
Deleting a macro from your personal macro workbook
Your personal macro workbook is a hidden file called PERSONAL.XLSB that Excel creates automatically the first time you record a macro with the "Personal Macro Workbook" option selected. Macros stored here run in any workbook you open on your computer. If you want to delete one, you must unhide the workbook first.
Go to the View tab on the ribbon. In the Window group, click Unhide. A dialog appears listing hidden workbooks — select PERSONAL and click OK. The personal macro workbook is now visible as a sheet tab at the bottom of your screen. Click the Developer tab, then Macros. In the dialog, look for the dropdown that says "Macros in:" and change it from your current workbook to "PERSONAL.XLSB". Select the macro you want to delete and click Delete. After you confirm, you can hide the personal macro workbook again by going to View, then Hide.
Understanding where macros are stored before you delete
When you record or write a macro, Excel asks you where to store it. The three options are: "This Workbook" (the file you are currently using), "New Workbook" (creates a new file), or "Personal Macro Workbook" (the hidden PERSONAL.XLSB file). Knowing where a macro is stored matters because deleting it from one location does not delete it from another.
If you delete a macro from your current workbook, it only disappears from that file. If the same macro is also in your personal macro workbook, it stays there. This is useful if you want to keep a macro for other projects but remove it from one specific file. However, it also means you may accumulate macros over time in your personal workbook that you no longer use.
Deleting macros stored in add-in files
Some macros come from Excel add-ins — special files with a .xlam extension that add features to Excel. These macros cannot be deleted through the Macros dialog because they are part of the add-in code itself. To remove them, you must disable or uninstall the add-in.
Go to File, then Options, then Trust Center, then Trust Center Settings, then Trusted Add-ins. Find the add-in you want to remove and click it. Look for a Disable or Remove button — the exact wording depends on your version of Excel. If you cannot find the option there, go to File, then Options, then Add-ins. At the bottom, change the dropdown from "Excel Add-ins" to "Disabled Add-ins" and look for the add-in there. Select it and click Remove.
What happens when you delete a macro
Once you delete a macro, it is gone permanently. You cannot undo the deletion by pressing Ctrl+Z. The macro will not run anymore, and any buttons or keyboard shortcuts linked to it will stop working — if you click a button that triggered a deleted macro, nothing happens.
If the macro was attached to a button on your spreadsheet, the button itself remains, but it no longer does anything. You can delete the button separately by right-clicking it and selecting Delete, or you can leave it there and reassign it to a different macro later. If the macro was triggered by a keyboard shortcut, that shortcut becomes available again for you to assign to a different macro.
Cleaning up unused macros from your personal workbook
Over time, your personal macro workbook can accumulate macros you no longer use. This does not slow down Excel noticeably, but it is cleaner to remove them. The process is the same as deleting any other macro from the personal workbook: unhide it, open the Macros dialog, change the location to PERSONAL.XLSB, select each macro you no longer need, and delete it.
If you want to see all the macros in your personal workbook at once, unhide it, then go to Developer, Macros, and set the dropdown to "PERSONAL.XLSB". This shows you every macro stored there. You can delete them one at a time or go through the list and remove the ones you recognize as old projects or experiments.
Frequently Asked Questions
Can I undo a macro deletion?
No. Once you click Delete and confirm, the macro is permanently removed. Pressing Ctrl+Z does not restore it. If you think you might need a macro again later, save a copy of the workbook before deleting it, or write down the macro code before you remove it.
What if I delete a macro but the button still appears on my spreadsheet?
The button remains because it is a separate object from the macro. Right-click the button and select Delete to remove it. If you want to keep the button but assign it to a different macro, right-click it, select Assign Macro, and choose a new one from the list.
Does deleting a macro from one workbook delete it from all my files?
No. Deleting a macro from your current workbook only removes it from that file. If the same macro exists in other workbooks or in your personal macro workbook, it stays there. You must delete it separately from each location.
How do I know if a macro is in my personal workbook or my current file?
Open the Macros dialog (Developer tab, then Macros). Look at the dropdown that says "Macros in:" — it shows you which location is currently selected. Click the dropdown to see all available locations and the macros stored in each one.
What if I accidentally delete a macro I still needed?
If you have a recent backup of the file, you can restore it from there. Otherwise, you will need to recreate the macro by recording it again or rewriting the code. Keep backups of workbooks that contain important macros so you can recover them if needed.