How to Update PivotTable When Source Data in Excel Worksheet Changes



     Webhosting by Godaddy     MS Excel Books
Home More Excel (VBA) Training Videos





How to Update PivotTable When Source Data in Excel Worksheet Changes by refreshing the Pivot Cache Using VBA
Now if you want the Pivot Table's PivotCache to refresh automatically  when a cell in the source data changes, you'll need to provide an appropriate code. We'll use the PivotTable's index property as shown in the VBA code below:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
End Sub

You can also use the following code to update the Pivot Table when the source data changes:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.PivotTables(1).RefreshTable
End Sub

Watch the video:





How to Update PivotTable When Source Data in Excel Worksheet Changes Using VBA

Watch the video on YouTube

References
Tom’s Tutorials For Excel: Automatically Refreshing Your Pivot Table

Home More Excel (VBA) Training Videos