Hi,
I have a workbook with many sheets and each sheet has several pivot tables. However, this workbook is copied from different workbooks and the pivot tables are referencing to the original workbooks. I want them all now to use the same Table1 as source data in the new workbook. So I wrote this:
The problem is my pivot tables are not ordered in 1,2,3,4,.....20. So it got errors. Can anyone help me out? Huge thx!!!!
I have a workbook with many sheets and each sheet has several pivot tables. However, this workbook is copied from different workbooks and the pivot tables are referencing to the original workbooks. I want them all now to use the same Table1 as source data in the new workbook. So I wrote this:
HTML:
Sub Macro1()
Dim ws As Worksheet
Dim abc As Integer
For Each ws In ThisWorkbook.Worksheets
For i = 1 To 20
abc = i
ActiveSheet.PivotTables("PivotTable" & abc).ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:="Table1", Version _
:=xlPivotTableVersion12)
Next i
Next
End Sub
The problem is my pivot tables are not ordered in 1,2,3,4,.....20. So it got errors. Can anyone help me out? Huge thx!!!!