Page 375 - Microsoft Office Excel 2003 Programming Inside Out
P. 375

Part 5:  Manipulating Excel Objects
                                                  PivotTables and PivotCharts

                    PivotTables Collection
                             The PivotTables collection contains the set of all PivotTables in a particular worksheet.
                             Table 16-1 lists the key properties and methods for the PivotTables collection. You can
                             access the PivotTables property from a Worksheet object using the following code:

                             ActiveSheet.PivotTables(1)

                             Table 16-1.  Key Properties and Methods of the PivotTables Collection
                             Property/Method            Description
                             Add(PivotCache,            Method: adds a new PivotTable to the collection.
                             TableDestination, TableName,   PivotCache refers to the data that will be displayed in the
                             ReadData, DefaultVersion)   PivotTable; TableDestination passes a Range object
                                                        whose upper-left corner marks the location of the
                                                        PivotTable in the worksheet; TableName contains the
                                                        name of the PivotTable (optional); ReadData, when True,
                                                        caches all records from an external database in
                                                        PivotCache; DefaultVersion specifies the version of Excel
                                                        that created the PivotTable.
                             Count	                     Property (read-only): returns the number of items in the
                                                        PivotTables collection.
                             Item(index)                Method: returns the PivotTable object reference
                                                        associated with index. Index may refer to the PivotTable
                                                        by either its name or its relative position in the
                                                                                                             Chapter 16
                                                        collection.

                    PivotTable Object

                             The PivotTable object represents a single PivotTable. You can use this object to access an exist­
                             ing PivotTable on a worksheet, or you can use the Add method from the PivotTables collec­
                             tion to add a new one. You can even use the PivotTableWizard method from the Worksheet
                             object to create a new PivotTable.
                             Table 16-2 contains a list of the key properties and methods associated with the PivotTable
                             object.
















                                                                                                       349
   370   371   372   373   374   375   376   377   378   379   380