How to Troubleshoot Empty VBA Query Results in Excel on Windows 11
Question details
The user needs to resolve an issue where an Excel VBA application returns empty query results when executing against an Oracle or SQL Server database.

- Product
- Microsoft Excel (Office 2013, Office 2021)
- Device & OS
- Windows 11
- Scenario
- Running an Excel VBA macro to connect and pull data from Oracle or SQL Server databases on a Windows 11 machine.
- Observed behavior
- The query returns no results on the Windows 11 machine, despite the exact same workbook and query functioning perfectly on another computer.
Before troubleshooting, ensure you have the exact login credentials for your Oracle or SQL Server databases and verify that your Windows 11 system has an active network connection to the database servers.
Verify and Update ODBC Drivers
Mismatched or missing ODBC drivers are the most common cause of VBA database connection failures across different computers.
VBA relies heavily on Windows ODBC (Open Database Connectivity) drivers to communicate with external databases. If the Windows 11 computer lacks the specific driver version installed on the working computer, the connection may silently fail or return empty recordsets.
Press the Windows key, type 'ODBC Data Sources', and open the version (32-bit or 64-bit) that matches your Excel installation architecture.
Navigate to the 'Drivers' tab and check if the required Oracle or SQL Server ODBC driver is installed and matches the version on the working computer.
If missing or outdated, download the appropriate driver from the official Oracle or Microsoft website and install it.
Re-establish the System DSN or User DSN in the 'System DSN' tab using the correct server credentials and use the 'Test Connection' button to verify it connects successfully.

Debug the VBA Connection String and Add Error Handling
Modify your VBA code to capture specific connection errors rather than silently returning empty datasets.
Post a Reproducible Question on Stack Overflow
If driver and code checks fail, specialized developer communities can assist with complex VBA database issues.
Try WPS Office for High Compatibility and Seamless Data Handling
While troubleshooting complex VBA and database connections in Microsoft Excel can be time-consuming, WPS Office offers a lightweight, highly compatible alternative for your spreadsheet tasks. It supports advanced formulas, robust data visualization, and macro execution in its Pro version, ensuring you can manage your data efficiently without the heavy resource footprint.
- 1. Download the Installer: Visit the official WPS website and download the WPS Office Free installer.
- 2. Install WPS Office: Run the downloaded file and follow the straightforward on-screen instructions to install the suite on your Windows 11 PC.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheets and open your existing .xlsx or .xlsm files to continue your data analysis work seamlessly.

Frequently Asked Questions
Why does my Excel VBA macro work on one Windows computer but not another?
This is usually caused by differences in installed software environments, such as varying bit-versions of Office (32-bit vs 64-bit), mismatched or missing ODBC database drivers, differing macro security settings, or missing VBA reference libraries on the new machine.
How do I check if my Excel is 32-bit or 64-bit on Windows 11?
Open Excel, click on 'File', then 'Account'. Click the 'About Excel' button. The top of the window will display your version and indicate whether it is 32-bit or 64-bit, which is crucial for installing the correct ODBC drivers.
Can I use VBA to connect directly to Oracle and SQL Server databases?
Yes, you can use ADODB (ActiveX Data Objects) in VBA to connect to external databases like Oracle and SQL Server. You must ensure the correct connection strings and ODBC/OLEDB drivers are installed and specified for each database type.
Where can I find the correct ODBC drivers for Windows 11?
ODBC drivers should be downloaded directly from the database vendor's official website. For SQL Server, download the Microsoft ODBC Driver for SQL Server. For Oracle, download the Oracle Data Access Components (ODAC) which includes the necessary ODBC driver.




