VBA Power Queries not waiting before running code

KimC2504

Board Regular
Joined
Jul 17, 2012
Messages
141
Hi All,

I have written the code below which works however I need it to stop after the first 5 queries and run the code to update formula's. Once this has finished, then run Query 6 - 12. At the moment all the queries run and then the code to update formula's runs. I have had to split this into 3 different routines which is not ideal. Any suggestions??

By the way, Background refresh is NOT enabled.



Code:
Sub UpdateALL()
 
        ActiveWorkbook.Connections("Query - 1 - RevenueImpactDeals").Refresh
        ActiveWorkbook.Connections("Query - 2 - InvalidOPPs").Refresh
        ActiveWorkbook.Connections("Query - 3 - MgtUpdates").Refresh
        ActiveWorkbook.Connections("Query - 4 - Judgement").Refresh
        ActiveWorkbook.Connections("Query - 5 - Debookings").Refresh
       
       << Code to update formula’s >>
     
       ActiveWorkbook.Connections("Query - 6 - SFDC #2").Refresh
        ActiveWorkbook.Connections("Query - 7 - MgtUpdates (2)").Refresh
        ActiveWorkbook.Connections("Query - 8 - Judgement (2)").Refresh
        ActiveWorkbook.Connections("Query - 9 - Debookings (2)").Refresh
        ActiveWorkbook.Connections("Query - 10 - Append1- SFDC#2 & Mgt Updates").Refresh
        ActiveWorkbook.Connections("Query - 11 - Append2-Append1 &  Judgment").Refresh
        ActiveWorkbook.Connections("Query - 12 - Append3-Append2 & Debookings").Refresh
 
 
     
End Sub
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,215,050
Messages
6,122,868
Members
449,097
Latest member
dbomb1414

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