Fix Excel for Microsoft 365 Crashing When Closing a VBA Module Window
Question details
Excel for Microsoft 365 repeatedly crashes when attempting to close a Visual Basic for Applications (VBA) module window.

- Product
- Microsoft Excel for Microsoft 365
- Device & OS
- not provided
- Scenario
- Editing or reviewing VBA macros in the Visual Basic Editor.
- Observed behavior
- The Excel application crashes entirely when the user closes a VBA module window, even if no VBA code is actively running at the time.
Ensure you save all your active workbooks and close any unnecessary background applications to prevent data loss while troubleshooting this crash.
Maximize the VBA Module Window Before Closing
A known temporary workaround for this bug is to maximize the module window prior to closing it, which prevents the window state conflict causing the crash.
This specific issue is often tied to a bug in how the Visual Basic Editor handles restored or floating window states.
Press ALT + F11 in Excel to open the VBA editor.
Click the Maximize button (the square icon) in the top-right corner of the VBA module window.
Once maximized, click the 'X' to close the VBA module window or press ALT + Q to return to Excel without crashing.

Install the Latest Microsoft 365 Updates
Since this crash is frequently caused by a specific Office build bug, applying the latest updates from Microsoft can permanently resolve the issue.
Launch Excel in Safe Mode
Running Excel in Safe Mode helps determine if an external add-in or extension is interfering with the VBA Editor and causing the crash.
Try WPS Office for Stable Spreadsheet Management
If Excel continues to crash due to unresolved build bugs, consider switching to WPS Office. It provides a lightweight, highly compatible alternative for handling complex spreadsheets without the heavy system crashes.
- 1. Download WPS Office: Visit the official WPS website to download and install WPS Office for free.
- 2. Open WPS Spreadsheets: Launch the application and select the Spreadsheets module.
- 3. Load Your Workbook: Open your macro-enabled files (.xlsm) and enjoy a stable editing experience.

Frequently Asked Questions
Why does Excel crash only when I close the VBA module?
This is a known bug in specific builds of Microsoft 365 where the Visual Basic Editor fails to correctly release memory or handle window state changes when minimized or restored.
Will I lose my macros if Excel crashes?
If you haven't saved your workbook before the crash, unsaved VBA code changes will be lost. It is highly recommended to frequently press CTRL + S while editing macros.
Does this VBA crash affect all versions of Excel?
This specific crash typically affects recent Microsoft 365 subscription builds. Older standalone versions like Excel 2016 or 2019 might not experience this exact VBA editor bug.
Where can I find the exact Office build number to report to support?
You can find your exact Office build number by opening Excel, clicking on 'File', then 'Account'. The build number is listed under the 'About Excel' section.




