cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
r96359
Helper IV
Helper IV

Use PAD to refresh specific queries from Excel Power Query and wait until refresh complete without VBA

Anyone know how to target specific queries from Excel Power Query and wait until refresh complete without VBA?

I several queries I need to run one after another to refresh and then move to the next one.

 

How do you call on a query?

How do you wait for refresh to be complete?

 

I think the old answer for me would be to create  vba code to refresh each specific query including a dialog box. Have PAD run the vba code and then wait for dialog box before going to next vba code for next query etc.

 

Any better way to get this done?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Alright, post back how does it go with you on disabling the 'Background Refresh' setting.

Also there are macros on the web that can programmatically disable this but at first you can do it via the settings.

View solution in original post

10 REPLIES 10
r96359
Helper IV
Helper IV

Really suprised there is no response on this question.

Is VBA code required to acomplish the ability to target a Power Query refresh?

Any suggestions on the best way to hande this?

Thanks

Ta daaaa 😁

I have to do something similar, run 3 separate macros with a wait in between.

 

 

Screenshot 2022-05-18 150839.png

@UK_Mike 

Hi there, 

How are you waiting for the refresh to complete?

Is there an intelligent way to handle this or are you just waiting for x seconds?

Thanks

Wait for x seconds as its unreliable waiting for the macro text on screen to finish.

Ive got circa 30 workbooks, 3 separate macros are stored in personal workbook.

So, for each workbook, refresh 1, wait 10 seconds, refresh 2, wait 10 seconds, refresh 3, wait 10 seconds.

Only takes a minute to open, 3 refreshes, 3 waits, save and close.

r96359
Helper IV
Helper IV

My queries run from a few seconds to a few minutes. I needs something reliable.

How did you find message box after completion unreliable? 

VJR
Super User
Super User

I have read that disabling background refresh makes the execution of the refresh macro pause until the query has completed and the data pulled in.

Can give it a try.

 

  • Go to Ribbon: [Data]
  • Click on [Connections]
  • Select the query you want to affect
  • Press [Properties]
  • Untick [Enable Background Refresh]

 

r96359
Helper IV
Helper IV

@VJR 

Thanks! I also just found for VBA using this statement after a query refresh makes it wait until the refresh is complete. I will try your idea as well.

"Application.CalculateUntilAsyncQueriesDone"

@VJR BTW My last ide of using "Application.CalculateUntilAsyncQueriesDone" doesn't seemt to work if power query is quering againt another worksheet table and not a external daetabase.

Alright, post back how does it go with you on disabling the 'Background Refresh' setting.

Also there are macros on the web that can programmatically disable this but at first you can do it via the settings.

r96359
Helper IV
Helper IV

@VJR Many thanks! Disabling the 'Background Refresh' setting did the job without the need for additional vba code.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,491)