I have a VBA macro (in Excel) that needs to refresh multiples QueryTable. It take a while but I know with the argument "BackgroundQuery" it is possible to make the refresh asynchronous. The issue is that I do not find a way to wait for all of them to finish before continuing my code.
Here is an extract of my current code:
' Refreshing CSV data (Export Availability) (BackgroundQuery:=False make the output sync)
With shExpAvlb.[export_availability].ListObject.QueryTable
.CommandText = "SELECT * FROM [export_availability] where Country='" & str_Country & "'"
.Refresh BackgroundQuery:=True
End With
' Refreshing CSV data (production) (BackgroundQuery:=False make the output sync)
With shProd.[production].ListObject.QueryTable
.CommandText = "SELECT * FROM [production] where Country='" & str_Country & "'"
.Refresh BackgroundQuery:=True
End With
' ? How to wait for them before continuing my code ?
Thanks a lot for your help !
Max