PivotTable.PivotTableWizard (Excel)

Creates and returns a PivotTable object. This method doesn't display the PivotTable Wizard. This method isn't available for OLE DB data sources. Use the Add method to add a PivotTable cache, and then create a PivotTable report based on the cache.

PivotTableWizard (SourceType, SourceData, TableDestination, TableName, RowGrand, ColumnGrand, SaveData, HasAutoFormat, AutoPage, Reserved, BackgroundQuery, OptimizeCache, PageFieldOrder, PageFieldWrapCount, ReadData, Connection)

ActiveCell.PivotTable.PivotTableWizard

Arguments

Optional arguments

The following arguments are optional

SourceType - An XlPivotTableSourceType value that represents the source of the report data. If you specify this argument, you must also specify SourceData. If SourceType and SourceData are omitted, Microsoft Excel assumes that the source type is xlDatabase, and the source data comes from the named range Database. If this named range doesn't exist, Excel uses the current region if the current selection is in a range of more than 10 cells that contain data. If this isn't true, this method will fail

SourceData - The data for the new report. Can be a Range object, an array of ranges, or a text constant that represents the name of another report. For an external database, SourceData is an array of strings containing the SQL query string, where each element is up to 255 characters in length. You should use the Connection argument to specify the ODBC connection string. For compatibility with earlier versions of Excel, SourceData can be a two-element array. The first element is the connection string specifying the ODBC source for the data. The second element is the SQL query string used to get the data. If you specify SourceData, you must also specify SourceType. If the active cell is inside the SourceData range, you must specify TableDestination as well

TableDestination - A Range object specifying where the report should be placed on the worksheet. If this argument is omitted, the report is placed at the active cell

TableName - A string that specifies the name of the new report

RowGrand - True to show grand totals for rows in the report

ColumnGrand - True to show grand totals for columns in the report

SaveData - True to save data with the report. False to save only the report definition

HasAutoFormat - True to have Excel automatically format the report when it's refreshed or when fields are moved

AutoPage - Valid only if SourceType is xlConsolidation. True to have Excel create a page field for the consolidation. If AutoPage is False, you must create the page field or fields

Reserved - Not used by Excel

BackgroundQuery - True to have Excel perform queries for the report asynchronously (in the background). The default value is False

OptimizeCache - True to optimize the PivotTable cache when it's constructed. The default value is False

PageFieldOrder - The order in which page fields are added to the PivotTable report's layout. Can be one of the following XlOrder constants: xlDownThenOver (default) or xlOverThenDown

PageFieldWrapCount - The number of page fields in each column or row in the PivotTable report. The default value is 0 (zero)

ReadData - True to create a PivotTable cache that contains all records from the external database; this cache can be very large. If ReadData is False, you can set some of the fields as server-based page fields before the data is actually read

Connection - A string that contains ODBC settings that allow Excel to connect to an ODBC data source. The connection string has the form ODBC;. This argument overrides any previous setting for the PivotCache object's Connection property

PivotTable.PivotTableWizard procedure builder