1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Sub Change_Pivot_TableDataSource()
Dim oPT As PivotTable
Dim oPC As PivotCache
Dim ORange As Range
Set oPT = Sheets("sheet1").PivotTables("PivotTable1")
Set oPC = oPT.PivotCache
Set ORange = Sheets("sheet2").Range("A2:AB" & Sheets("shee").Range("C65536").End(xlUp).Row)
oPC.SourceData = "TD_Reporting_EU_Breakdown!" & Application.ConvertFormula(ORange.Address, xlA1, xlR1C1)
oPT.RefreshTable
If Not oPT Is Nothing Then Set oPT = Nothing
If Not oPC Is Nothing Then Set oPC = Nothing
End Sub |
Partager