Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Newbie22
Resolver I
Resolver I

VBA MsgBox AFTER Background Query Completion

Hi!

 

Is it possible to create a message box that will show if the refreshing/loading of Queries are completed?

 

Right now, I'm just looking at the bottom part of my Excel to know if it's still loading. I'd like to know if I can create a message box that will pop up once loading is done.

 

Newbie22_1-1693308376852.png

Here's my VBA code:

 

Sub RefreshAll()
'
' RefreshAll Macro
'
' Keyboard Shortcut: Ctrl+Shift+R
'
ActiveWorkbook.RefreshAll

End Sub

1 REPLY 1
Martin_D
Solution Sage
Solution Sage

Hi @Newbie22 ,

 

you have 2 options to achieve this:

 

  1. f you don't want to continue working in Excel while the refresh is ongoing, then you can turn off background refresh for each query and so the next line of code after RefreshAll(), which could be a MsgBox, will only execute after refresh is done.
     
    Martin_D_1-1693326210200.png 
  2. If you want to continue working in Excel while RefreshAll() is executing in the background, then you can implement an AfterRefresh event handler for each query. Once refresh has finished for all refreshes, e.g. count how many AfterRefresh Events already occured, then finally show the message box. Example see here: http://www.vbaexpress.com/forum/showthread.php?30743-DoEvents-ActiveWorkbook-RefreshAll-Run-second-p...

BR

Martin

github.pnglinkedin.png

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.