I have a VBA code that refreshes my data connections twice and then calculates the workbook. I added On Error Resume Next, but when there is an error with the query refreshing it ignores my VBA error handling and shows an error saying "Unexpected Error, Something went wrong. If the problem continues, please restart Excel." After i click cancel it continues with my code but the one query that caused the error still shows its running even though the other queries ran after it. I turned off background refresh on all connections already and i am just trying to find some VBA code where i can handle the error with power query.
Eventually i would want my code to cancel the query that caused the error and refresh it individually after all the code is done.
How do we handle errors in power query with VBA?
Current code:
On Error Resume Next
ActiveWorkbook.RefreshAll
ActiveWorkbook.RefreshAll
ActiveWorkbook.Calculation = xlAutomatic
On Error Resume Next
will capture errors thrown by the VBA compiler, not the Excel application. – dwironyRefreshAll
s in there? – dwirony