Pages

Saturday, July 9, 2011

Change the source of pivot table in VBA Excel

if you want to change the source data of existing pivot table using VBA.

Here is the code-

'Sheets("Sheet1").Range("a1:d20") is new source
Sub change_source_data()
With Sheets("Pivot Table 2").PivotTables("PivotTable1").PivotCache
.SourceData = Sheets("Sheet1").Range("a1:d20").Address(True, True, xlR1C1, True)

End With

End Sub

Excel Macro File http://www.filefactory.com/file/cc42dcd/n/pivot_tables_in_vba.xlsm

No comments:

Post a Comment