VBA & Macro Problems

Fix Excel Macros Disappearing or Failing to Run in Microsoft 365

Huma Ashraf ChHuma Ashraf Ch Oct 8, 2026 874 views

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.

Fix Excel Macros Disappearing or Failing to Run in Microsoft 365
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 you start

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.

Solution 1Recommended

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.

1
Check macro settings

In Excel, navigate to File > Options > Trust Center. Click 'Trust Center Settings' and then 'Macro Settings'. Ensure that macros are temporarily enabled for troubleshooting.

2
Backup existing VBA code

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.

3
Remove the old workbook

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.

4
Create a new personal macro workbook

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.

5
Restore the backed-up code

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.

Configure Trust Center and Rebuild Personal.xlsb
Testing Your Setup: After restarting Excel, try running your macros right away. If they execute correctly without vanishing, your macro environment is successfully repaired.
Free Microsoft Office alternative

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. 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. 2. Open your Macro-Enabled File: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb workbook directly.
  3. 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.
Fully compatible with Microsoft Excel macro-enabled formats (.xlsm, .xlsb, .xltm).Provides a highly stable and reliable VBA macro execution environment.Lightweight architecture that loads quickly and consumes fewer system resources.Free to download with a familiar ribbon interface, ensuring a seamless migration from Microsoft Office.
microsoft office alternative - wps office

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.