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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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