Pivot Tables Collection

You can use another method to create a PivotTable from a PivotCache, using the Add method of the PivotTables collection. If you have already created a PivotCache in your workbook and you want to create a second PivotTable, you can use the following code:

Sub AddTable()

Dim pvc As PivotCache Dim pvt As PivotTable

'Access existing PivotCache

Set pvc = ActiveWorkbook.PivotCaches(l)

'Add new PivotTable to PivotTables collection

Set pvt = ActiveSheet.PivotTables.Add(PivotCache:=pvc, _


End Sub

There is no particular advantage to using this method compared with the CreatePivotTable method. It's just another thread in the rich tapestry of Excel.

0 0

Post a comment