Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Removing All Macros.

Removing All Macros

Written by Allen Wyatt (last updated October 17, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


4

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 three ways you can accomplish this task. The first (and easiest) method is to simply use Save As (press F12) and use the Save As Type drop-down list to specify that you want to save the workbook in XLSX format. This approach removes all macros as they cannot be saved in this workbook format.

The second approach is essentially a variation on the "new workbook" approach:

  1. Unhide any worksheets that may be hidden.
  2. 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.)
  3. Right click on one of the worksheet tabs. Excel displays a Context menu.
  4. Choose Move or Copy from the Context menu. Excel displays the Move or Copy dialog box. (See Figure 1.)
  5. Figure 1. The Move or Copy dialog box.

  6. Using the To Book drop-down list, choose (new book).
  7. Make sure the Create Copy check box is not selected.
  8. Click on OK.
  9. Re-hide any worksheets you unhid in step 1.

Your worksheets have now been moved to a new workbook—one that does not have any macros attached to it. You can now save the new workbook using any file format you desire.

The third 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:

  1. Press Alt+F11 to display the VBA Editor.
  2. 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.
  3. 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.
  4. When asked if you want to export the module before removing it, click on No.
  5. Repeat steps 2 through 4 for any other modules you want to remove.
  6. Close the VBA Editor.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10656) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Removing All Macros.

Author Bio

Allen Wyatt

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. ...

MORE FROM ALLEN

Setting a Spacing Adjustment in the Equation Editor

The Equation Editor is a handy tool when you are creating documents that rely on mathematical formulas. If you want to ...

Discover More

Rounding To the Nearest Even Integer

Do you need your numbers to be rounded to an even integer value? How you accomplish the task depends on the nature of the ...

Discover More

Filtering to a Date Range in the Past

If you have a large number of data records, each with an associated date, you might want to filter that data so you see ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Using Seek In a Macro

When reading information from a text file, your macro may need to start reading at a place other than the beginning of ...

Discover More

Adding Leading Zeroes to ZIP Codes

Import a bunch of ZIP Codes into Excel, and you may be surprised that any leading zeroes disappear. Here's a handy little ...

Discover More

Making Modal Dialog Boxes Appear in Front of Workbooks

Perhaps the most common way of communicating with programs is through the use of dialog boxes. We expect dialog boxes to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2020-10-19 02:39:06

Alex B

I also don't know why you would use any method other that the 1st one.
If you went with option 2 to copy the sheets, an additional problem you would encounter is that you would have to copy each sheet that included a table individually (or use Ron De Bruin's copy sheets macro).


2020-10-17 17:53:24

Roy

@Willy: Even if you don't want to change the extension, just Save As the .xlsx then Save As back over the .xlsm. Delete, probably, the .xlsx (depending upon why you wanted the clean of macros file, and it's all over. No questions asked.


2020-10-17 09:22:45

Alan Cannon

All macros are not stored in modules. Some can be stored in a worksheet's code "window" and some in the workbook "window".


2020-10-17 06:35:19

Willy Vanhaelen

Saving the file as an .XLSX file is the only method that will for sure remove all macros.

The other two approaches suppose there are only macros in modules but each worksheet or chartsheet has its own code page that can contain macros too especially event macros. The ThisWorksheet code page can have macros as well. They all remain there unless you delete them manually which can be tedious.

The third approach can only be useful if you really don't want to change the extension but then take care of checking the sheet code pages.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.