Vba code to wait until query & calculations are complete before proceeding

BennyBB

New Member
Joined
Sep 6, 2013
Messages
33
I am looking for VBA code sample for the following situation....


My excel code currently does a REFRESH ALL DATA. At which point in the lower left is displayed the message, "RUNNING BACKGROUND QUERY ... (CLICK HERE TO CANCEL)". Also later at times when I refresh, I get a message, "CALCULATING: (4 PROCESSOR(S)): ##%"....

Is there a was in VBA to have my code pause until these messages disappear? These messages go away on there own with time & patients.

I want a closed loop solution and don't want to input a pause unless there is a way to check TRUE/FALSE if either message is displayed (is preferred).


Thanks,


BennyB

P.S. Win7 64, Office 2013 32bit.
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

CalcSux78

Well-known Member
Joined
Oct 15, 2013
Messages
1,120
With RefreshAll, your code is most likely resuming the next lines before all connections are refreshed.

Instead, try refreshing each connection (one by one). The code should wait until refresh is completed before resuming the next line. If you have multiple connections, you could loop through all connections with something to this effect:

Code:
Dim Conn As WorkbookConnection

For Each Conn In ThisWorkbook.Connections
    Conn.Refresh
Next Conn
 

Watch MrExcel Video

Forum statistics

Threads
1,099,679
Messages
5,470,097
Members
406,681
Latest member
sachinmasurkar

This Week's Hot Topics

Top