0

I am hoping someone can help. I initially had an issue where I could not get a MsgBox to appear AFTER a query had been refreshed. Instead the box would arrive immediately after the query begins refreshing however the query was still processing. The query is via Power Query. I managed to get around this by clicking in the query properties, disabling background refresh and using Application.EnableEvents

What I am now looking for is if one of the PowerQuery queries is unable to fetch an update, it reads the status and MsgBox "Sorry but the " & QueryName & "is unable to retrieve the data. Please ensure the data is loaded in the system".

Sub FetchData()

Sheets("Conc").Unprotect Password:="Password"

Application.DisplayAlerts = False
Application.EnableEvents = False

    ActiveWorkbook.RefreshAll

Application.EnableEvents = True

MsgBox "Refresh is now complete!"
    
    Sheets("Conc").Range("E2").Value = "ATs " & Format(Now(), "mmm-yy")
    Sheets("Conc").Range("E5").Value = Application.UserName
    Sheets("Conc").Range("E3").Value = Range("A8").Value & " 0001/" & Format(Now(), "mm")

Application.DisplayAlerts = True

Sheets("Conc").Protect Password:="Password"

End Sub
MBrann
  • 209
  • 5
  • 21
  • Check out https://stackoverflow.com/questions/22083668/wait-until-activeworkbook-refreshall-finishes-vba – Dave Jul 14 '21 at 13:19

0 Answers0