Forum Discussion
VBA Wait for Query Refresh
Hi Excel Community,
I am having issues with a detailed macro that requires multiple queries to be refreshed several times throughout the running of the VBA code to allow the user to visualise updates that are being sent to the company SQL database. The issue occurs where the code continues to run even while the queries are still refreshing, meaning that the code is completing calculations within the workbook based on the old data within the query tables rather than the new data that was just sent to the SQL database through previous steps of the same macro.
I have done a fair bit of trialling based on other discussions and forums around the same issue but none have worked so far (i.e. Query Background Refresh is greyed out/unticked already, trialled using
1 Reply
- JKPieterseSilver ContributorImpossible to answer without seeing at least some relevant bits of your code I'm afraid.
You don't mention what type of query you are talking about, e.g. is this through the legacy query wizard, PowerQuery, VBA, some other connection? A QueryTable object has a Refreshing property which should tell you if it is -well- refreshing.