Deleting a macro is something to learn when you no longer need macros in your excel workbook or you wish to delete a particular macro in the workbook. We would learn how to delete all the macros in the excel workbook and delete only the selected macro that we no longer want. We might want to re-record because of some problems we did while recording the macro in the first go.
So here we begin.
How to Delete a Selected Macro?
Let us suppose we have four macros in our excel workbook. You can check the list of macros in your workbook either from the View tab or from the Developer tab on the ribbon. Learn to add the Developer tab on the ribbon from here.
- Click on the Macros button in the View tab on the ribbon.
- Alternatively, use the developer tab on the ribbon to see the list of macros in the workbook.
- A shortcut to open the list of macros in a workbook is pressing the alt and F8 keys.
This would open the list of all macros in this workbook as follows.
- Select the macro that you no longer require and then press the delete button at the right.
If the macro is not shown in this list, then you need to check if the macro was recorded in the personal macro workbook. Macros recorded in the Personal Macro workbook can be used in all the workbooks that you use in your excel version. Change the Macros in Field to Personal.xlsb
How to Delete All the Macros from Excel Workbook?
There are two ways to delete all the macros in excel workbook in one go. The first method is to save the excel macro-enabled workbook as a normal .xlsx file. The second method is to remove the module that contains code for the workbook macros in the VBA editor.
Method 1 – Saving the Workbook as .XLSX file
Saving the workbook as a .xlsx file would change its format to a normal excel file that has no macros and consequently this action would erase all the macros written in that workbook.
We will use Save As command to create a copy of the workbook that would have all macros erased.
- Go to the File tab on the ribbon.
- Move to the Save As menu and select a location where you want to save the macro-free workbook.
- Set the Save As type to Excel Workbook. Click On Yes for saving it as .XLSX file
Doing this will erase all the macros. You can open the file disabling macros.xlsx to check.
Method 2 – Use the VBA editor to Delete the Module containing Macros
To perform the deletion of all existing macros in the current workbook through the VBA editor, follow these steps:-
- Press Alt and F11 keys together to open the VBA editor.
- Alternatively, use the Developer tab. Click on Visual Basic Button.
- This opens the VBA interface.
- Go to the Module part of the currently opened workbook in the project explorer window and click on Module 1.
- Module 1 contains the macros. Clear all of them and press the Alt F4 keys to close the VBA editor.
This brings it to an end.
Thank you for reading.