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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.