Refreshing External Data and Pivot Tables

dotman

New Member
Joined
Sep 2, 2008
Messages
7
Hi,

I have a excel report template which contains approx 9 pivot tables and 4 external data feeds from more than one access db. I am looking to automate production of this report so there is little or no input from the user.

So... I am looking to write some code which will refresh each of the pivots and external data ranges individually (not all at the same time as excel won't like that), in order and only once the previous has been succesfully refreshed. A vb message box would also be good to indicate to the user what is currently being refreshed.

Anyone have any ideas/suggestions or experience of doing anything similar?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Assuming it doesn't matter what order the external data ranges are refreshed in:
Code:
Sub RefreshTheData()
    RefreshAllQueries
    RefreshAllPivots
End Sub
 
Sub RefreshAllQueries()
   Dim wks As Worksheet
   Dim qt As QueryTable
   For Each wks In ActiveWorkbook.Worksheets
       For Each qt In wks.QueryTables
           qt.Refresh False
       Next qt
   Next wks
End Sub

Sub RefreshAllPivots()
   Dim pc As PivotCache
   For Each pc In ActiveWorkbook.PivotCaches
      pc.Refresh
   Next pc
End Sub

Just run the RefreshTheData sub.
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,535
Members
449,169
Latest member
mm424

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
Back
Top