I have the following code so it automatically refreshes all my external web data queries (background refresh) of my entire Workbook when I run this Macro every 2 minutes in a loop.
Sub RunMacro()
Dim wbc As WorkbookConnection
Dim pc As PivotCache
For Each wbc In ThisWorkbook.Connections
wbc.Refresh
Next wbc
For Each pc In ThisWorkbook.PivotCaches
pc.Refresh
Next pc
Application.OnTime Now + TimeValue("00:02:00"), "RunMacro"
End Sub
But how do I specify so that this Macro is run not every 2 minutes exactly, but run immediately after the background refresh has finished, in a loop (as in, imagine that refreshing any given webpage in Internet Explorer does not always take the exact amount of time every time I do so).
Bookmarks