VBA & Macro Problems

Fix Excel VBA QueryTable Refresh Crashes After Microsoft 365 Upgrade

Anum MushtaqAnum Mushtaq Oct 23, 2026 869 views

Question details

Excel crashes or produces automation errors when running VBA macros to refresh MS Query QueryTables after updating to Microsoft 365.

Fix Excel VBA QueryTable Refresh Crashes After a Microsoft 365 Upgrade
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a VBA macro to update and refresh legacy MS Query data connections in a workbook after a recent Microsoft Office update.
Observed behavior
Excel throws an automation error or completely crashes when returning data to the worksheet. Furthermore, the built-in workbook recovery process often corrupts or damages the file permanently.
Before you start

Create a complete backup copy of your workbook before running or testing any VBA macros, as Excel's automatic recovery process may severely corrupt the file during this specific crash.

Solution 1Recommended

Declare the ListObject Variable Explicitly in VBA

Update your VBA code to store the target table in an explicit variable before triggering the refresh method to prevent memory and automation errors.

Inline references to ListObjects can sometimes cause memory handling issues in newer builds of Microsoft 365, leading to sudden crashes when data is returned from MS Query.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel, and locate the module containing your refresh macro.

2
Update the VBA Code

Find the line causing the crash, typically written as 'Sheet2.ListObjects(1).QueryTable.Refresh (False)'. Replace it with explicit variable declarations: Dim Listobj As ListObject Set Listobj = Sheet2.ListObjects(1) Listobj.QueryTable.Refresh False Listobj.Range.AutoFilter

3
Run and Test

Save your code and run the macro again. Storing the ListObject in a variable ensures Excel properly handles the object reference during the background query refresh.

Declare the ListObject Variable Explicitly in VBA
Code Updated: By explicitly defining the ListObject, VBA handles the memory reference more securely, preventing the automation error during data retrieval.
Free Microsoft Office alternative

Try WPS Office for a Stable Spreadsheet Experience

If Microsoft Excel continues to crash or corrupt your workbooks after updates, consider switching to WPS Office. It provides a lightweight, highly compatible alternative for handling complex spreadsheets and data analysis without the heavy overhead of Microsoft 365.

  1. 1. Download and Install: Get the free WPS Office installer from the official website and complete the quick installation process.
  2. 2. Open Your Workbooks: Launch WPS Spreadsheets and open your existing Excel (.xlsx or .xlsm) files directly.
  3. 3. Manage Your Data Safely: Enjoy a stable, crash-free environment while managing your data tables and spreadsheet connections.
Fully compatible with Microsoft Excel formats (.xlsx, .xls, .csv, .xlsm)Lightweight architecture that prevents heavy resource crashesIntuitive user interface similar to Microsoft Office for seamless migrationRobust built-in support for advanced formulas, charting, and data filtering
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel's recovery process damage my workbook after a VBA crash?

When Excel crashes mid-refresh while running an MS Query update, the file's internal XML structure can become corrupted or left incomplete. Excel's automatic recovery tries to strip out the broken elements, which often results in the permanent removal of your tables, connections, or VBA modules.

Will Power Query connections crash in VBA like MS Query?

Generally, Power Query (Get Data) is much more robust and stable in newer Microsoft 365 versions. Migrating legacy MS Query connections to Power Query and refreshing them via VBA typically resolves legacy automation errors entirely.

Can I downgrade Microsoft 365 to fix the QueryTable crash?

Yes, if your organization allows it, you can roll back Microsoft 365 to a previous build where the legacy MS Query refresh functioned correctly. You will need to use the Office Deployment Tool or command-line updates to revert to an older version.