VBA Refresh All Pivot Tables

Mudbutt

Board Regular
Joined
Jul 18, 2011
Messages
158
Is there a difference between these two procedures to refresh all pivot tables on a workbook? I've been finding that not all my pivots have been refreshing with this first option so I was going to try the second one I have here. Any ideas?

#1
Code:
For Each ws In Activeworkbook.Worksheets
        For Each pt In ws.PivotTables
            pt.RefreshTable
        Next pt
    Next ws
#2
Code:
Activeworkbook.RefreshAll
 
The first one still works. What's the data source for the pivot tables?
 
Upvote 0

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
The first one still works. What's the data source for the pivot tables?

My source is a data tab within the workbook, nothing really fancy.

I was trying to link a button (Form Control button) to a refresh pivots macro. I want to prompt the refresh of all my pivots only, but the "RefreshAll" macro is the only thing that would work. I don't necessarily want "all" updated, as I have an ODBC-linked table that others do not have the connection to, nor authority to connect.

It's been a while since I did this, but it worked in 2003.

Thanks, Bill
 
Upvote 0
So if you manually change some of the existing data and run that code, the pivots don't alter?
 
Upvote 0
I'm not positive, but unless you have Calculation set to manual, that seems unlikely to me.
...

THANK YOU for posting that! I have a macro that used to crash and the Calc was set to manual and wasn't being reset! I had forgotten to check that! Yes! THANK YOU!
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

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