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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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