by Allen Wyatt
(last updated June 18, 2018)
Gerald asked if there was a way to get rid of all the macros in an Excel workbook, without the need to individually delete them. There are two ways you can accomplish this task. The first approach is used if you don't want to mess with the macros at all. Just follow these steps:
- Unhide any worksheets that may be hidden.
- Select all the worksheets in the workbook. (Click on the first worksheet tab, then hold down Shift as you click on the last worksheet tab.)
- Right click on one of the worksheet tabs. Excel displays a Context menu.
- Choose Move or Copy from the Context menu. Excel displays the Move or Copy dialog box. (See Figure 1.)
Figure 1. The Move or Copy dialog box.
Your worksheets have now been moved to a new workbook—one that does not have any macros attached to it.
The second approach is to simply work with the existing workbook, and is a viable choice if you feel comfortable with macros in the first place. Follow these steps:
- Press Alt+F11 to display the VBA Editor.
- In the Project Explorer (upper-left corner of the Editor), right-click on a module that you want to delete. (Remember that macros are stored in modules, and that you should only right-click on a module that is associated with the workbook that you want to cleanse.) Excel displays a Context menu.
- Choose the Remove option from the Context menu. The actual wording of the option will include the name of the module you want to remove, such as Remove Module1.
- When asked if you want to export the module before removing it, click on No.
- Repeat steps 2 through 4 for any other modules you want to remove.
- Close the VBA Editor.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2713) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Removing All Macros.
With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen.