delay a VBA to wait for refresh all to finish? autocalcs turning back on too soon

bauerbach

New Member
Joined
Sep 12, 2013
Messages
33
I have a super simple macro, infact, its only purpose is to turn off autocalcs, refresh all, and then turn autocalcs back on.

problem is, while the query tables are still refreshing, it finishes the macro, which means it recalcs all the table updates... Completely missing the point of the whole thing.

Is there a way to pause the macro until the queries are finished running?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;">Application.Wait(Now + #0:00:01#)</code></pre>
 
Upvote 0
that can work, no way to make it intelligent to know when the queries are done?

this will be better than nothing atleast. Thanks

edit: or maybe it is doing that... awesome if it is! wont know for sure till I can refresh things again tomorrow morning.
 
Last edited:
Upvote 0
In the connection properties for each query table, you can try un-checking the option "Enable background refresh"
 
Upvote 0
Try putting the following line between the Refresh land turning the calculation back to automatic
Code:
DoEvents
 
Upvote 0
Do this at the top of the macro.

Code:
Do Until Application.CalculationState = xlDone
    ActiveWorkbook.RefreshAll
    Loop
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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