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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It 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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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