MS-Excel / General Formatting

Enabling Macros When You Don't Have Any

Excel's memory is like a steel trap when it comes to remembering that you recorded a macro in your workbook. Unfortunately, its memory of macros persists even though you might have since deleted one or more macros via Developer → Macros or Alt/Option-F8 (pre-2007, Tools → Macro → Macros). Reopen the workbook and you'll still be prompted to enable macros, even though there are none to enable.

You'll be prompted to enable macros only if your security level is set to "Disable all macros with notification" (Medium in pre-2007 versions). If it's set to "Enable all macros" (Low in pre-2007 versions), macros are enabled without a peep; if it's set to "Disable all macros without notification" (High in pre-2007 versions), macros are disabled automatically for your protection.

When you record a macro, Excel inserts a Visual Basic module to hold your commands and home-brewed functions. Upon opening a workbook, Excel checks for the presence of modules, whether empty or macro-filled. Deleting a workbook's macros deletes any code within the module, not the module itself-kind of like drinking the last of the milk, yet putting the empty carton back in the fridge. To avoid the unnecessary macro prompt, you need to remove the module. Here's how to do that.

Open the VBE by selecting Developer → Visual Basic under Code options or by pressing Alt/Option-F11 (pre-2007, Tools → Macro → Visual Basic Editor and select View → Project Explorer).

On the Macintosh and in Excel 2007, the Projects window is always open, so you don't need to open the Project Explorer.

Find your workbook in the Project Explorer and click the plus sign (+) to its left to expose the workbook's component parts, particularly the modules if they are not already showing. Right-click each module in turn and choose Remove Module from the context-sensitive menu. Decline the offer to export the modules. Before blithely removing modules that might contain useful code, double-click each module in turn to make certain you don't need them. Press Alt-Q as usual to get back to Excel's spreadsheet view.

[Contents] [Next]

In this tutorial:

  1. Prevent Unnecessary Prompts
  2. Enabling Macros When You Don't Have Any
  3. Prompting to Save Nonexistent Changes