title: Error handling Power Query refresh with VBA
body: <p>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. </p>
  
  <p>Eventually i would want my code to cancel the query that caused the error and refresh it individually after all the code is done.</p>
  
  <p>How do we handle errors in power query with VBA?</p>
  
  <p>Current code:</p>
  
  <pre><code>On Error Resume Next 
  ActiveWorkbook.RefreshAll 
  ActiveWorkbook.RefreshAll 
  ActiveWorkbook.Calculation = xlAutomatic
  </code></pre>