How to Update PivotTable When Source Data in Excel Worksheet Changes

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:


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

2 thoughts on “How to Update PivotTable When Source Data in Excel Worksheet Changes

  1. swaley gokhool

    dear sir how do we update the pivot table when it is found on the next worksheet where do we need to input the code in worksheet 1 or 2

    Reply
  2. Pingback: Best Training on Advanced Excel and VBA in Bangalore | jaseemblog

Leave a Reply

Your email address will not be published. Required fields are marked *