I have VBA code that refreshes an Excel table using a sproc
With ActiveWorkbook.Connections("Connection").OLEDBConnection
Values = QueryStr
.CommandText = Values
End With
Once the refresh has completed I need to apply some formatting (trhough VBA code), the problem with this is that the code executes without waiting for the refresh to end, therefore the VBA macro fails, is there a way I could tell the macro to wait until the refresh has completed?
Thanks
Try setting the BackgroundQuery property to False.
Code:
If i’m not mistaken.. this’ll prevent the updates from running in the background, so it’ll have to complete before the rest of your code executes.