Understanding Phantom Macros

Written by Allen Wyatt (last updated September 9, 2023)
This tip applies to Excel 97, 2000, 2002, and 2003


Are you up for an experiment? Try the following: open a brand new workbook in Excel; one that has no macros in it. Record a quick macro, and then delete it. Save the workbook, close it, and reopen it. If all went as expected, Excel should have warned you about the workbook when you reopened it, and asked you if you wanted to disable the macros.

This sounds odd—after all, you know there are no macros in the workbook. Are there phantom macros at work here? No, not really. The reason Excel behaves this way is that when you create your first macro in a workbook, Excel creates a new module in which to retain the macro. When you later delete the macro, the module remains behind, ready to hold any other macros you may create. It is modules that Excel checks for when you open a workbook, not individual macros. If there is a module, you get the warning.

To fix this situation, you must follow these steps:

  1. Make sure the offending workbook (the one with the phantom macros) is open.
  2. Press Alt+F11, or choose Macros from the Tools menu and then choose Visual Basic Editor from the resulting submenu. Excel displays the Visual Basic Editor.
  3. Near the upper-left side of the editor is the Project Explorer. This contains a hierarchical tree that shows the different modules in your workbook. If the Project Explorer is not visible on your screen, press Ctrl+R to display it.
  4. Within the Project Explorer should be a folder called Modules. If it is not already open, double-click on the Modules folder to display its contents.
  5. Right-click on a module in the folder. A Context menu is displayed.
  6. Choose the Remove option from the Context menu. You are asked if you want to export the module before removing it.
  7. Click on the No button. The module is removed.
  8. Repeat steps 5 through 7 for each module in the Modules folder.
  9. Close the Visual Basic Editor.
  10. Resave your workbook.

At this point your workbook contains no modules, and you will not get any notification when you subsequently open it.

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 (2011) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Inserting Page Number Cross-References

Want to insert a dynamic cross-reference to a particular page number? It's easy to do following the steps in this tip.

Discover More

Eliminating "Before Spacing" at the Top of a Page

When formatting paragraphs in Word, you have several options to adjust the spacing before, within, and at the end of each ...

Discover More

Specifying the Behavior of the Enter Key

You type information in a cell and press Enter. What happens then? Excel allows you to specify exactly what should ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Filling a Range of Cells with Values

When writing a macro, you may want to fill a range of cells with different values. The easiest way to do this is to use ...

Discover More

Creating Worksheets with a Macro

Using a macro to add worksheets to your workbook is easy. This tip provides two different methods you can use.

Discover More

Deleting a File in a Macro

Macros give you a great deal of control over creating, finding, renaming, and deleting files. This tip focuses on this ...

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 2 + 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.