Refresh Pivot Tables Automatically

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I know that in the Pivot Table Options you can
check 'Refresh on Open', which will allow you to refresh
all pivot tables when you close the file and reopen it.

I have a workbook with multiple pivot tables and I'd like
to have them all refresh at the click of a button when I
make changes to the underlying data (without having to
close and reopen the file). I tried recording a macro,
but got an error when running it. Is there a way to make
this work?

Thx!
 
Hi
use the following macro
Sub Refresh_Pivot()

Dim ws As Worksheet
Dim pt As PivotTable

On Error Resume Next
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next
Next
End Sub
 
You may want to look at refreshall in VBA's help:

ThisWorkbook.RefreshAll
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top