Power Query Problems

How to Switch Power Query Results in the Same Excel Table

Phi Hung VoPhi Hung Vo Oct 28, 2026 869 views

Question details

The user needs to dynamically switch between two different Power Queries and output their respective results into the exact same table location in an Excel workbook.

How to Switch Power Query Results in the Same Excel Table
Product
Microsoft Excel
Device & OS
not provided
Scenario
Managing multiple data queries in a single Excel dashboard without creating separate tables or sheets for each query.
Observed behavior
The user wants a method to replace the existing table data with the results of a different selected query on demand.
Before you start

Ensure your workbook is saved as an Excel Macro-Enabled Workbook (.xlsm), as you will need to use VBA scripts to clear and refresh the query data dynamically.

Solution 1Recommended

Use VBA Macros to Switch Queries

Automate the process of clearing the current table and loading a new query result into the same location using a VBA script.

Excel does not natively support hot-swapping different Power Queries into a single table through the standard interface. To achieve this, you must write a VBA macro that acts as a switch. The macro will clear the existing data, update the query connection, and refresh the table.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to launch the Visual Basic for Applications (VBA) editor in Excel.

2
Insert a New Module

Click on Insert in the top menu and select Module to create a blank script area for your macro.

3
Write the Clearing Code

Write a script that targets your specific ListObject (the Excel table). Use the DataBodyRange.ClearContents method to empty the table before running the new query.

4
Update the Query Connection

Add code to change the table's QueryTable or Connection property to point to the new Power Query you wish to execute.

5
Execute the Query

Add the command Refresh BackgroundQuery:=False to execute the newly selected query and populate the cleared table. You can then assign this macro to a button on your spreadsheet for easy switching.

Use VBA Macros to Switch Queries
Power BI Alternative: If you are trying to switch query results in Power BI rather than Excel, post your question in the Power BI community. You can typically achieve similar results in Power BI using Field Parameters or Bookmarks without needing VBA.
Free Microsoft Office alternative

Try WPS Office for Your Data Management Needs

While advanced Power Query configurations and VBA swapping are specific to Microsoft Excel, WPS Office provides a lightweight, highly compatible, and free alternative for everyday data analysis and spreadsheet management. Enjoy a familiar interface with seamless migration for your standard workbooks.

  1. 1. Download the Installer: Visit the official WPS website to download the free installation package for your operating system.
  2. 2. Install WPS Office: Run the installer and follow the on-screen prompts to set up WPS Office on your device.
  3. 3. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing .xlsx or .csv files to continue your data analysis without formatting issues.
Completely free and lightweight with a familiar, easy-to-use tabbed interface.Fully compatible with Microsoft Excel formats (.xlsx, .xlsm, .csv) to ensure seamless file sharing.Features robust built-in data analysis tools, pivot tables, and advanced formulas.
microsoft office alternative - wps office

Frequently Asked Questions

Can I switch Power Query results in the same table without using VBA?

No, Excel does not have a native point-and-click feature to hot-swap queries into the exact same table. Standard behavior requires loading different queries to separate sheets or distinct tables.

Why does my Excel table duplicate when I load a new query?

If you attempt to load a new query to an existing location without properly clearing the old data and replacing the connection, Excel will create a new ListObject (table) next to or below the old one to avoid overwriting existing data.

Is it possible to toggle data views dynamically in Power BI instead?

Yes. In Power BI, you can achieve a similar user experience without macros by using Field Parameters or Bookmarks to swap which data or visual is displayed on your dashboard.