VBA to update SQL Statement in Power Query?

ImpetuousRacer

New Member
Joined
May 12, 2010
Messages
9
I'm on Office 365.

I created an ODBC connection to Google BigQuery. After selecting the data source as Google BigQuery, I expand "Advanced Options" and there is an option for "SQL Statement (optional)".
I paste my SQL Code in there and run the query, and have it create a table with the results.

I want the data table to refresh with a new SQL code generated from input fields.

I have a user input field for ID, Start Date, and End Date on a separate sheet.
  1. Using VBA, I have the SQL code on that page update from the inputs from the input fields. This code is then copied to the clipboard. (Done).
  2. I would like to then refresh the data table results using the new SQL query (Where I'm stuck).

Right now I have to go to the data table, Query>Edit>Applied Steps>Source>Settings>Replace the code>Re-Run
or Query>Edit>Home Tab>Advanced Editor>Replace Code

To automate this, I'd like to ideally enter the 3 inputs, press button, data table refreshes with new SQL Statement. Done.

Thanks for the help on this.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top