PivotTables Object (Excel)
Published: July 16, 2012
A collection of all the PivotTable objects in the specified workbook.
The Workbook.PivotTables property (which is new for Microsoft Office 2013) does not return all the PivotTable objects in the workbook; instead it returns only those associated with decoupled PivotCharts. However, Worksheet.PivotTables returns all the PivotTable objects in the worksheet, irrespective of whether they are associated with decoupled PivotCharts.
Because PivotTable report programming can be complex, it’s generally easiest to record PivotTable report actions and then revise the recorded code.
Use the PivotTables method to return the PivotTables collection. The following example displays the number of PivotTable reports on Sheet3.
Use the PivotTableWizard method to create a new PivotTable report and add it to the collection. The following example creates a new PivotTable report from a Microsoft Excel database (contained in the range A1:C100).
Use PivotTables(index), where index is the PivotTable index number or name, to return a single PivotTable object. The following example makes the Year field a row field in the first PivotTable report on Sheet3.