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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
Super User
Super User

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.