Pivot table macro

nishpearl123

Board Regular
Joined
Jun 14, 2010
Messages
96
Hi,

I have 10 pivot reports from one database.

Everytime i change the database, i have to individually "Refresh" all the Pivot.

Is there any shortcut?

Regards,

Ni****h
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi,

i tried what you suggested. but first of all it on running the macro it gives an error "400".

and secondly my pivot table are in 10 different worksheets but from the code it appers that if would work on all pivot table in a single sheet.

kindly assist.

regards,

ni****h
 
Upvote 0
non-programatic option is:
  • Right click on each pivot table
  • Select Table options
  • Tick the 'Refresh on open' option.
  • Click on the OK button
This will refresh the pivot table each time the workbook is opened.

here are a couple of other options with vba
Code:
Refresh all pivots in Workbook – Method 1
Sub PT_1()
For Each pt In ActiveWorkbook.PivotCaches
pt.Refresh
Next pt
End Sub
Refresh all pivots in Workbook – Method 2
Sub PT_2()
For Each sht In ActiveWorkbook.Worksheets
For Each pt In ActiveSheet.PivotTables
pt.RefreshTable
Next pt
Next sht
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,874
Members
452,949
Latest member
Dupuhini

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