Microsoft Office Tutorials and References
In Depth Information
20.3 The PivotTableWizard Method
Note that the page button is labeled Year. Selecting one of All, 1998, or 1997 from the drop-down
list box next to this button will confine the data to that selection. Thus, the pivot table has three
pages: 1997, 1998, and combined (or All).
Note also that the columns are labeled by periods and the rows are labeled by both Store City and
Store Type, as requested. In addition, Excel has created a new field called Data that is used as row
labels. In this case, Excel correctly guessed that we want sums, but if Excel had guessed
incorrectly we could make a change manually.
In summary, we can see that the main components of a pivot table are the pages, rows, columns,
and data fields.
Rather than pursue further development of this PivotTable using the Excel interface, let us now
switch to using code.
20.3 The PivotTableWizard Method
To create a PivotTable through code, we use the PivotTableWizard method of the Worksheet
object or the PivotTable object. Contrary to what you might assume, the PivotTableWizard
method does not start the PivotTable wizard. Rather, it is used to create a PivotTable when applied
to the Worksheet object or to modify an existing PivotTable when applied to the PivotTable object.
The syntax is:
expression .PivotTableWizard( SourceType , SourceData , TableDestination , _
TableName , RowGrand , ColumnGrand , SaveData , HasAutoFormat , _
AutoPage , Reserved , BackgroundQuery , OptimizeCache , _
PageFieldOrder , ageFieldWrapCount , ReadData , Connection )
where expression returns either a Worksheet object or a PivotTable object. As you might
expect, the parameters of the PivotTableWizard method correspond to settings in the PivotTable
wizard. On the other hand, the PivotTableWizard method cannot do everything that the PivotTable
Search JabSto ::

Custom Search