ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Adding button to worksheet to refresh pivot table data (https://www.excelbanter.com/excel-worksheet-functions/161717-adding-button-worksheet-refresh-pivot-table-data.html)

Ron

Adding button to worksheet to refresh pivot table data
 
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

Roger Govier[_3_]

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





All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com