Macro is generally used to automate repetitive tasks. In Microsoft Office programs like Excel, a macro is created providing a series of instructions to execute. When a macro gets executed, it performs the task step-by-step based on provided instructions. For example, we could have a macro that tells Excel to save all the charts as images in a specified folder.
In Excel, you can create a new macro by writing some VBA codes or you can record a new macro to perform some task upon pressing shortcut keys.
In case you want to make an Excel Workbook macro-free then you can delete all macros (or remove a single macro only).
In this tutorial, I will show you 3 simple ways to remove macros from Excel Workbook. Here you will learn how to remove all macros at once and how to delete a specific macro only.
Reverting Excel file back into XLSX format:
Reverting a macro-enabled Excel file back into normal XLSX format is the simple and best solution for removing all macros at once.
This method is not for you if you are willing to remove only some specific macros from your Excel Workbook.
By default, an Excel Workbook saved in XLSX format is macro-free. If you save your XLSM (macro-enabled Workbook) file in XLSX format, all the macros will be removed automatically while saving.
Suppose you have a macro-enabled Excel file called result_sheet.xlsm, follow the steps mentioned below to remove all macros at once from this file:
Step 1: If you are in Excel version 2007 then go to the Office button, otherwise, go to the File tab if you are using the latest Excel version. Then, clicking on the “Save As” option will open the Save As dialogue box.
You can also open the Save As dialogue box directly by pressing shortcut key F12 on the keyboard too.
Step 2: On the Save As dialogue box, you can save the file as the same name or enter the new name. Within the Save As dialogue box, clicking on the “Save as type” labeled box will open a dropdown where you can find various file formats such as xlsx, xml, txt, csv and so forth.
Now you have to choose the XLSX format and then click on save.
Step 3: As you click on the Save button, a new prompt will open on your screen to confirm whether you want to save as a macro-free workbook or not. We are removing macros so we need to click on the YES button.
That’s all ! Finally you removed all macros from your Excel Workbook at once.
Delete Specific Macros:
In the first method, we discussed how to delete all the macros from Workbook at once but what if you need to delete specific macros.
The Macro dialogue box allows you to choose the specific macros and delete them manually.
Suppose you have a macro-enabled Excel file called SalesDemo.xlsm and you need to delete only two macros then follow the steps mentioned below:
Step 1: Go to Developer tab, click on the Macros which is available on Code group. Clicking on Macros will open the Macro dialogue box where you can see all the macros that you have created inside a Workbook.
You can directly open the Macro dialogue box by pressing ALT + F8 shortcut key on keyboard.
Step 2: If you want to delete specific macros from the current Workbook only then make sure ‘This Workbook’ is selected. If not selected, you can choose it from the ‘Macros In’ dropdown box.
Step 3: After you choose the Workbook, it’s time to choose a macro name that you want to remove. Then clicking on the ‘Delete’ button will remove a selected macro from the macro list.
If you need to delete more macros then repeat the step 3.
This method takes time but it is best if you need to delete specific macros and don’t want to make a macro-free Excel Workbook.
Delete a Macro from the Visual Basic Editor:
We use Visual Basic Editor to write some lines of code that create a new macro inside our Workbook. You can also remove macros from the VB editor.
Carefully follow the steps mentioned below to remove macros from VBA editor:
Step 1: Go to Developer tab, click on the Visual Basic option (i.e. located inside Code group). Clicking on the Visual Basic will open the VB editor. You can directly open the VB editor by pressing the shortcut key ALT + F11 on the keyboard.
Step 2: On the left pane of the VB editor, you will see the Project Explorer box which contains all the workbook objects. If you couldn’t locate the Project explorer in the left pane then go to View menu and then click on the Project Explorer option. You can also directly show Project Explorer by pressing CTRL+R shortcut key on keyboard.
Step 3: When we create macros, all the macros are stored on the Modules object. Thus removing a module also removes the macro from our Workbook.
To remove a module, right click on the selected module and then choose remove command.
Alternatively you can remove macro by double clicking the module and then select all the code and press the delete.
That’s it ! These are the 3 simple methods for removing macro from Excel Workbook.
After removing macro code, make sure macro dialogue box is empty.
If you have any problem while removing macros then feel free to mention your problem on the comment box.