View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Roger Govier[_3_] Roger Govier[_3_] is offline
external usenet poster
 
Posts: 2,480
Default Adding button to worksheet to refresh pivot table data

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 PTTable 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 PTView codePaste code into the white pane.

--
Regards
Roger Govier



"Ron" wrote in message
...
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