VBA code to refresh Child Pivot Table

H

HKS

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).PivotCache.BackgroundQuery =
True

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top