Forum Discussion
blueinfo
Mar 06, 2026Copper Contributor
After closing a workbook, it still shows in the VBA project list
After closing a workbook, it still shows in the VBA project list. When working with multiple Excel files this is a pain. How to avoid or close the VBA projects, without closing Excel complete...
NikolinoDE
Mar 09, 2026Platinum Contributor
In Excel, when you close a workbook, its VBA project may still appear in the VBA project list. This usually happens because the VBA Editor (VBE) maintains a reference to the workbook. To avoid this or to close VBA projects without closing Excel entirely, you can follow these suggestions:
Manually Close the VBA Editor:
Press Alt+F11 in Excel to open the VBA Editor.
In the VBA Editor, locate and close the window for the VBA project that corresponds to the workbook you've closed.
If you no longer need to use the VBA Editor, you can close the entire VBA Editor window.
Use VBA Code to Close Workbooks and Clean Up References:
- You can write VBA code to close workbooks and, before closing, perform any necessary cleanup to reduce the likelihood of VBA projects lingering in the VBA project list. However, note that the standard Workbook.Close method does not directly provide functionality for cleaning up VBA project references.
- Here's a simple VBA code example to close the current workbook without saving changes (this does not directly clean up VBA project references but demonstrates how to close a workbook via VBA code):
Sub CloseWorkbookWithoutSaving()
ThisWorkbook.Close SaveChanges:=False
End Sub- If you want to perform cleanup operations before closing a workbook (though this typically doesn't involve directly cleaning up VBA project references), you can add the relevant code before closing.
Disable Macros (If Applicable):
- If you're concerned about the security of VBA projects or want to reduce Excel's startup time, consider disabling macros. However, be aware that this will prevent all VBA code from executing, including macros that might be useful to you.
- To disable macros, typically you would: open Excel Options, navigate to the Trust Center, open Trust Center Settings, select Macro Settings, and choose the option to disable all macros.
I hope this helps clarify how to manage VBA projects in Excel when closing workbooks!