Adding button to worksheet to refresh pivot table data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a daily input worksheet and it kicks out the results to a pivot
table. I want to create a button on that chart for the user to click on so
it can refresh data. Doing so just in case they don't have the pivot table
menu open, or forget to click in chart to bring up the refresh data button
 
Hi Ron

Add the following code to the button on your sheet

Sub Refresh_Pivot()
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
End Sub

Change the name of the Pivot Table to the correct one for you.
To find the name, right click on your PT>Table Options> name will be shown
at top of dialogue.

Alternatively, rather than attaching code to a button, you could use a
worksheet event to cause the PT to be refreshed as soon as the tab is
selected.

Private Sub Worksheet_Activate()
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh

End Sub

The above code needs to be copied, then right click on the sheet tab with
the PT>View code>Paste code into the white pane.
 
Back
Top