ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA code to refresh Child Pivot Table (https://www.excelbanter.com/excel-discussion-misc-queries/186535-vba-code-refresh-child-pivot-table.html)

HKS

VBA code to refresh Child Pivot Table
 
In one workbook, I have three parent pivot tables and ten child pivot tables.
I want a macro to refresh these child tables from different parent tables. I
wrote a macro and it always has the runtime error in the following code
(second row of the code). Any advise/idea?

Dim vWSMain as Parent PivotTable worksheet
Dim vWSChild as Child PivotTable worksheet
Dim vTableChild as Child PivotTable
Dim vTableParent1 as Parent PivotTable #1

Set vTableChild = ActiveCell.PivotTable
Worksheets(vWSMain).PivotTableWizard SourceType:=xlPivotTable, _
SourceData:=vTableParent1
Worksheets(vWSChild).PivotTables(vTableChild).Pivo tCache.BackgroundQuery =
True

Thanks



All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com