0

I have an Excel workbook containing multiple Query Tables. Each table has its own data link.

To refresh the data in all the Query Tables, I want the User to click the Refresh All button on the Ribbon.

I have a block of VBA code I want to run automatically once all the tables have completed being refreshed.

If there was only one table, I could use the AfterRefresh event as a trigger for the code I want to run. For a single table, the solution posted here works well: How to run VBA code after the "Refresh All" is pressed

However, since there are multiple tables, I think this might not be a good option.

For example, let's say I set the code to be triggered by the AfterRefresh of a particular table. We'll call it "Table Green". Additionally, let's say that When that "Table Green" has finished being refreshed, one of the other tables is still in the process of being refreshed. Let's call that one "Table Blue". Since "Table Green has finished being refreshed, the code is triggered. But since "Table Blue" is still in process, the outcome is not what is wanted.

From what I have read, when using the Refresh All button there is no good way to know the order in which tables will be refreshed. Nor is there a way to know which will complete first.

Additionally, over time, the number of Query Tables within the workbook may change, e.g. a new table may get added and/or a table may get removed.

How can this be accomplished?

  • Can the user hit a button to run the VBA once the refresh is complete? – Michael Murphy May 27 '22 at 19:09
  • Well, yes, but that's not the goal. The goal is to have the user click the Refresh All button, which will refresh the data in all the Query Tables, and then to have a block of code automatically run once all the tables have finished being refreshed. – Michael Schulz May 27 '22 at 19:26

0 Answers0