ADSkinner072
New Member
- Joined
- Jun 2, 2021
- Messages
- 3
- Office Version
- 2016
- Platform
- Windows
Hello all...I have been working on some code and trying to piece together bits and pieces to make a working file.
I have a worksheet with 5 individual pivot tables that I need to change the data source for and would like to do this by means of VBA.
I was able to find the code below, but it is giving me an error when I attempt to run it. Any help in figuring out what is my issue would be greatly appreciated.
I have a worksheet with 5 individual pivot tables that I need to change the data source for and would like to do this by means of VBA.
I was able to find the code below, but it is giving me an error when I attempt to run it. Any help in figuring out what is my issue would be greatly appreciated.
Code:
Public Sub My_04b_Resource_Pivots()
Dim pt As PivotTable
For Each pt In ActiveWorkbook.Worksheets("Team Performance").PivotTables
pt.ChangePivotCache ActiveWorkbook.PivotCaches.Create _
(SourceType:=xlDatabase, SourceData:="Data")
Next pt
End Sub