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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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