I've got a macro that's supposed to refresh an external data table, and then create a pivot table from that data.
Code
Sheets("ReturnsData").Range("a2").QueryTable.Refresh
MsgBox ("On you go")
Run "PERSONAL.XLS!CreateReturnsPivot"
I thought that Excel would wait until the table finished refreshing before even going on to the next line. That wasn't the case, and the pivot was all buggy and empty because there was no data in the table yet. You see that I tried to put in a MsgBox to let me control how long to wait before proceeding in the code, but the MsgBox actually interrupted the Refresh command--not allowing the data to query the source until I clicked OK in the message box.
Any ideas about delaying the pivot creation until the table is refreshed?