VBA to Refresh Pivot Table and Chart

findingcindy

New Member
Joined
Apr 3, 2025
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
Good morning! I have the code below that changes the value on my pivot table on another sheet but it does not refresh the pivot table, therefore my pivot chart doesn't refresh. Any help would be greatly appreciated.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim PT As PivotTable
Dim Field As PivotField
Dim NewCat As String

Set PT = Worksheets("Chart").PivotTables("PivotTable6")
Set Field = PT.PivotFields("Filter")
NewCat = Worksheets("Scorecard").Range("b4").Value
ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh


End Sub
 
I don't see in the code where any cell value is changed.

Also, It sounds like the pivot table is not on the Active sheet; Is that correct?

Try changing this...
VBA Code:
ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh
To this...
VBA Code:
PT.PivotCache.Refresh
 
Upvote 0
Solution
I don't see in the code where any cell value is changed.

Also, It sounds like the pivot table is not on the Active sheet; Is that correct?

Try changing this...
VBA Code:
ActiveSheet.PivotTables("PivotTable6").PivotCache.Refresh
To this...
VBA Code:
PT.PivotCache.Refresh
Thank you so much. I did need to adjust the PT and changed the active sheet part to your suggestion. Thanks!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top