VBA to wait untill first refresh finishes then continue the second refresh

jjkh58

New Member
Joined
Apr 21, 2021
Messages
2
Office Version
  1. 365
  2. 2013
  3. 2011
  4. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi guys,

I have a report that needs to be refreshed twice before I can work on other stuff.

So what I usually do is go to Data - > Refresh All Then once the first refresh is completed, I press Ctrl+Alt+F5 to refresh for the second time.

Its refreshing multiple power queries with multiple tabs. The current code that I'm using but not working are below.

All other execution must be stopped before the first refresh is completed and needs to continue for the second refresh. Again, all other execution must be stopped until the second refresh finishes. Please help! Cheers.


Sheets("Sales Data").Select
Activeworksheets.RefreshAll
DoEvents

Sheets("GP by Department").Select
Activeworksheets.RefreshAll
DoEvents
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,553
Office Version
  1. 2010
Platform
  1. Windows
Hi,​
as explained in the VBA help for RefreshAll - a must read ! - you can edit the BackgroundQuery property of each object to refresh …​
 

jjkh58

New Member
Joined
Apr 21, 2021
Messages
2
Office Version
  1. 365
  2. 2013
  3. 2011
  4. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hi,​
as explained in the VBA help for RefreshAll - a must read ! - you can edit the BackgroundQuery property of each object to refresh …​
Hi Marc,
Thanks for your help. Im quite new to this coding area. Would you be able to explain more in detail please?. How and where exactly should I format my script? Thanks in advance
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,553
Office Version
  1. 2010
Platform
  1. Windows

Not by code, just editing manually the property of each object to refresh …​
 

Forum statistics

Threads
1,143,677
Messages
5,720,249
Members
422,272
Latest member
ginkgoVil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top