Microsoft Office Tutorials and References
In Depth Information
The PivotItem object represents a single, specific value for a particular PivotField object. Table
16-6 contains a list of the key properties and methods associated with the PivotItem object.
Table 16-6. Key Properties and Methods of the PivotItem Object
Property (read-only): returns the label text for the field.
Property (read-only): returns a Range object with the data
contained in the field.
Property: contains the formula associated with the item in A1-
style notation. If the cell is empty, an empty string will be
returned. If the cell contains a constant, the constant will be
Property (read-only): returns the Range object representing the
cells in the PivotTable report that contain the item.
Property: contains the name of the PivotItem object.
Property: contains the relative position of the field within its
Property (read-only): returns the number of records in the
PivotCache containing the specified item.
Property: contains the name of the specified item in the
Property: when True , means that the item is visible.
Programming PivotTables involves creating the appropriate PivotCache object and then
using the PivotCache object to create a PivotTable object. Once the PivotTable object is
available, you can modify its properties to view the data from different positions.
Tip Make Things Easy on Yourself
Creating PivotTables can be difficult, so you might want to fall back on the standard macro
writer’s trick: record a new macro using the commands necessary to perform the task you
wish to program, and then use the recorded code as the basis of your new program. This
trick is extremely useful when dealing with complex object models such as those used by
Excel to manipulate PivotTables.