Forum Discussion
TawfiqMugdha
Apr 01, 2024Copper Contributor
VBA Code for Pivot Table refresh
Hello everyone! I have this code, that refreshes all the pivot tables in the workbook. Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim p As PivotCache For Each p In This...
HansVogelaar
Apr 01, 2024MVP
Right-click the sheet tab of the Sales Hygiene Pivot sheet.
Select View Code from the context menu.
Copy the following code into the worksheet module:
Private Sub Worksheet_Activate()
Me.PivotTables(1).PivotCache.Refresh
End Sub
This will update the pivot table each time you switch to the Sales Hygiene Pivot sheet to view the pivot table.
Do the same for the other sheets with pivot tables.