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. To avoid the unnecessary macro prompt, you need to remove the module. Here’s how to do that.
- Open the VBE by pressing
Alt+F11
(orOption+F11
) - Select
View » Project Explorer
(if the Projects window is not opened). - Find your workbook in the Project Explorer
- Click the plus sign (+) to its left to expose the workbook’s component parts
- Click the plus sign to the left of the Modules folder to list any modules on board.
- Right-click each module in turn and choose
Remove Module
from the context menu. Decline the offer to export the modules. - Press
Alt+Q
to get back to Excel’s spreadsheet view. - Save your workbook.
Now, close and reopen the workbook, you’ll not see any prompt asking you to enable macros.
How to Disable “Enable Macro” Prompt for all Workbooks
You’ll be prompted to enable macros only if your macros setting is set to “Disable VBA macro with notification”.
If it’s set to “Enable VBA macro…”, macros are enabled without a peep.
if it’s set to “Disable VBA macro without notification”, macros are disabled automatically for your protection.
You can disable the macro security settings in Excel, but this is not recommended as it can expose your computer to potential risks from malicious macros.
- Click
Home > Options
. - Click
Trust Center > Trust Center Settings
. - Click
Macro Settings
and choose “Enable VBA Macros”
Now all workbooks containing macros will open without showing any prompt.