PDA

View Full Version : Refreshing Pivot Tables



Treeza
09-23-2008, 08:30 AM
Hi,

I'm trying to create a macro button to refresh 'any' pivot table - preferablly keeping the macro in my personal workbook.

However, when I Have created it:

Sub Refresh_pivot()
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub

It does not work if there are more than one pivot tables to a workbook. I'm certain it has something to do with the infomation in the () but I dont know how to change this to include 'any' pivot. It's probably REALLY simple - but I'm relatively new to macro creating.

Please help if you can.

Thanks in advance

Teresa

Slyboots
09-23-2008, 10:58 AM
Try this:

Sub Refresh_Pivot()
Dim t as integer
For t = 1 to ActiveSheet.PivotTables.Count
ActiveSheet.PivotTables(t).PivotCache.Refresh
Next t
End Sub


Hi,

I'm trying to create a macro button to refresh 'any' pivot table - preferablly keeping the macro in my personal workbook.

However, when I Have created it:

Sub Refresh_pivot()
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub

It does not work if there are more than one pivot tables to a workbook. I'm certain it has something to do with the infomation in the () but I dont know how to change this to include 'any' pivot. It's probably REALLY simple - but I'm relatively new to macro creating.

Please help if you can.

Thanks in advance

Teresa

Treeza
09-24-2008, 01:15 AM
Thank you so much Slyboots! :o)

JWhite
09-25-2008, 10:52 AM
I have several pivottables in each workbook but they all use the same pivotcache. I started out by refreshing each pivottable but that caused the pivotcache to re-load for every pivottable.

That's probably not a problem if you don't have much data but we sometimes have over a gigabyte. So I just refresh one pivottable, the pivotcache reloads one time, but ALL the pivottables change to show the new values.