VBA & Macro Problems

Troubleshoot VBA Code Disappearing in Excel XLSM Files

Emma BrownEmma Brown Nov 12, 2026 870 views

Question details

The user needs to diagnose Excel macro-enabled XLSM files where VBA code appears to disappear, workbooks crash, or macros run much more slowly than expected.

Troubleshoot VBA Code Disappearing in Excel XLSM Files
Product
Microsoft Excel for Microsoft 365
Device & OS
not provided
Scenario
Opening, repairing, and running VBA macros in multiple macro-enabled tracking workbooks that use buttons and UserForms.
Observed behavior
Some XLSM files crash when opened or when a button or UserForm is used. VBA code may appear to be missing, and previously fast macros may take several seconds to run.
Before you start

Work from a local copy of the affected XLSM workbook rather than a network share or synced folder. Note the Excel version and build number, the exact error message, and whether the problem began after a Microsoft 365 update.

Solution 1Recommended

Test the XLSM file locally and isolate macro security or add-in conflicts

Use this method when the workbook opens inconsistently, macros are blocked, or crashes occur when buttons or UserForms run.

Testing in a trusted local folder helps distinguish workbook damage from network, synchronization, security, or add-in issues. Enable macros only for files and locations that you trust.

1
Create a local test copy

Copy the affected .xlsm file to a local folder such as Documents, then open the local copy in Excel instead of opening it from a network drive, email attachment, or cloud-synced location.

2
Check macro security settings

In Excel, select File > Options > Trust Center > Trust Center Settings > Macro Settings. Review the selected macro setting, then use Trusted Locations to add only a secure local test folder if your organization permits it.

3
Disable Excel add-ins for testing

Select File > Options > Add-ins. At the bottom, choose Excel Add-ins or COM Add-ins from the Manage list, select Go, clear add-ins temporarily, and restart Excel. Re-enable them one at a time to identify a conflict.

4
Test on another computer

Open the same local test copy on another computer with Excel. If it works there, compare Excel build numbers, installed add-ins, antivirus controls, and permissions between the two computers.

Test the XLSM file locally and isolate macro security or add-in conflicts
Macro security matters: Do not lower macro security globally or enable content for files from unknown sources. Use a trusted location only for workbooks you control.
Free Microsoft Office alternative

Use WPS Office for everyday XLSM workbook access and spreadsheet work

If Microsoft Excel stability or update behavior is disrupting routine spreadsheet work, WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and seamless migration for common Office documents. WPS Spreadsheets can open and edit Excel-format workbooks, helping teams continue standard worksheet tasks while Microsoft-specific VBA issues are investigated.

Free and lightweight office suite for routine spreadsheet workOpen and edit Microsoft Excel .xlsx and .xls workbook formatsFamiliar spreadsheet tools and interface help reduce migration timeUseful for reviewing worksheet data when an Excel environment needs further troubleshooting
microsoft office alternative - wps office

Frequently Asked Questions

Can Excel Open and Repair restore VBA code that has disappeared?

Open and Repair may repair workbook structure and allow an XLSM file to open, but it cannot reliably reconstruct deleted or corrupted VBA project content. Open the repaired file with Alt+F11 and restore missing modules or UserForms from a known-good copy when available.

Why do XLSM files work locally but fail on a network drive?

Network interruptions, sync conflicts, permissions, or security policies can affect how an XLSM file is opened and saved. Copy the file to a local folder for testing, then check the network location, access permissions, and synchronization software if the local copy works.

Where can I check whether Excel is blocking macros?

In Excel, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. You can also review File > Options > Trust Center > Trust Center Settings > Trusted Locations for approved local folders.

How do I determine whether an Excel add-in is causing a VBA crash?

Go to File > Options > Add-ins, choose COM Add-ins or Excel Add-ins in the Manage box, then select Go. Disable all add-ins, restart Excel, and re-enable them individually while testing the affected workbook.

What information should I send to Microsoft Support for an XLSM crash?

Include the Excel version and build from File > Account > About Excel, the crash or error details, the time the problem started, installed add-ins, whether the file is local or network-based, and the smallest reproducible XLSM sample or set of steps.