Refresh pivot table when source data changes

anad63

New Member
Joined
Feb 17, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
So I'm running into an issue with some VBA code which states that if the source data changes, refresh the pivot table. If you look at image1 source, the pivot table in "Sheet 7" refresh fine if I manually change the week in A2. Which is great, the code is running in the "Calculation" sheet and as stated when you update the week number the pivot table refreshes.

The problem is in the sheet "AMS (for product)" I have a scroll bar (Image 2 course) that changes the week number in sheet "Calculation" and ultimately updates the data based on the week it is. When I use the scroll bar to update the number, the pivot table data does not refresh when the source data changes. I tried to copy paste the same code I put into "Calculation" but it doesn't seem to have an effect.

Private Sub Worksheet_Change(ByVal Target As Range)
Sheet4.PivotTables("PivotTable3").PivotCache.Refresh
End Sub
 

Attachments

  • Image1 source.JPG
    Image1 source.JPG
    63.5 KB · Views: 21
  • Image 2 source.JPG
    Image 2 source.JPG
    32.2 KB · Views: 21

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Refresh pivot table when source data changes
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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