I have already scoured the internet (eg. 1 2 3 ) for the answer, but all of them seem to provide a rather convoluted answer, which the users raised with specific conditions that are characteristic only to their own project, I intend this question to cut straight to the chase and bit more of a useful general learning resource. The question is:
How can I update my Pivot Table Source to a specific table range?
I have a Worksheet
called "Summary" that contains the following ListObject
(table) called "t_sum"
Issue is, upon a Workbook name change, the link to the pivot table gets broken and refreshing them returns the following error:
I tried something very simplistic in style of (that is invoked on every time workbook is opened)
Private Sub fix_pivot_source
For Each pivot in Sheets("Summary").PivotTables
pivot.SourceData = "Summary!t_sum"
Next pivot
End Sub
That however doesn't seem to work. Another issue is, given this is a financial report, the data is refreshing and so do the pivot table names. So I can't just directly reference them in the PivotCache
Any idea how can I link to the static table name while taking the Workbook name out of the equation - effectively ommitting it from SourceData check?