Fix Excel Macros Disappearing or Failing to Run in Microsoft 365
Question details
User needs a solution for VBA macros that disappear from the Visual Basic Editor or fail to execute, despite the modules still being present in the workbook.

- Product
- Microsoft 365 Excel
- Device & OS
- not provided
- Scenario
- Attempting to view, edit, or execute existing VBA macros in an Excel workbook.
- Observed behavior
- Macro modules remain visible, but the VBA code inside vanishes from the Visual Basic Editor and macros fail to run. The code only reappears temporarily when using the Open and Repair feature.
Before modifying your Macro Settings or deleting system files, carefully export any visible VBA modules to a local folder and create a backup copy of your workbook.
Configure Trust Center and Rebuild Personal.xlsb
Reset your macro security settings and recreate a fresh personal macro workbook to permanently restore the vanished VBA code.
Often, code disappears because the existing Personal Macro Workbook (Personal.xlsb) has become corrupted or Microsoft 365 Trust Center settings are aggressively blocking execution. Rebuilding the file from scratch clears out the corruption.
In Excel, navigate to File > Options > Trust Center. Click 'Trust Center Settings' and then 'Macro Settings'. Ensure that macros are temporarily enabled for troubleshooting.
Open the Visual Basic Editor (Alt + F11), copy your macro code from the existing Personal.xlsb modules, and paste it into a safe Notepad file.
Close Microsoft Excel entirely. Open File Explorer, navigate to your XLSTART folder (typically C:\Users\[Your Username]\AppData\Roaming\Microsoft\Excel\XLSTART), and delete or rename the Personal.xlsb file.
Reopen Excel. Go to the View tab, click Macros, and select 'Record Macro'. In the 'Store macro in' dropdown, choose 'Personal Macro Workbook', click OK, and then immediately stop recording to generate a fresh file.
Open the Visual Basic Editor again, paste the code you saved in Notepad into the modules of the newly created Personal.xlsb, and restart Excel to verify the macros remain visible.

Use Open and Repair to Extract Hidden Code
If your macros are hidden but modules remain, using Excel's built-in repair tool can force them to become visible long enough to copy the code out.
Try WPS Office for Stable Macro Execution
If Microsoft 365 continues to lose your VBA code due to application glitches or cloud sync issues, consider switching to WPS Office. It provides a lightweight, highly compatible spreadsheet environment that seamlessly supports Microsoft Excel macro formats (.xlsm, .xlsb) without the frustrating file corruption or expensive subscription fees.
- 1. Download and Install WPS Office: Visit the official WPS website, download the free installer, and complete the quick installation process on your device.
- 2. Open your Macro-Enabled File: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb workbook directly.
- 3. Enable Macros and Run Code: Click the prompt at the top of the workspace to enable macros, ensuring your VBA code runs smoothly without unexpected disappearances.

Frequently Asked Questions
Where can I find the Personal.xlsb file on my computer?
By default in Windows, the Personal.xlsb file is saved in the XLSTART directory. This is typically located at C:\Users\[Your Username]\AppData\Roaming\Microsoft\Excel\XLSTART. You may need to enable 'Hidden items' in File Explorer's View tab to see the AppData folder.
Why are my Excel macros suddenly disappearing in Microsoft 365?
Macros commonly disappear due to strict Trust Center security updates blocking execution, file corruption within the Personal.xlsb workbook itself, or conflicts caused by OneDrive attempting to sync open macro-enabled files incorrectly.
How do I securely export a VBA module to back it up?
Press Alt + F11 to open the Visual Basic Editor. In the Project Explorer pane on the left side of the window, right-click the module you want to back up, choose 'Export File', and save it as a .bas file to a local drive folder.




