PivotCaches.Create procedure builder

PivotCaches.Create (Excel)

Creates a new PivotCache.

The following two XlPivotTableSourceType constants are not supported when creating a PivotCache by using this method: xlPivotTable and xlScenario. A run-time error is returned if one of these two constants is supplied. The SourceData argument is required if SourceType isn't xlExternal. It should be passed a Range object (when SourceType is either xlConsolidation or xlDatabase) or a WorkbookConnection object (when SourceType is xlExternal). When passing a Range object, we recommend that you either use a string to specify the workbook, worksheet, and cell range, or set up a named range and pass the name as a string. Passing a Range object may cause "type mismatch" errors unexpectedly. When not supplied, the version of the PivotTable will be xlPivotTableVersion12. The use of the xlPivotTableVersionCurrent constant is not allowed and returns a run-time error if it is supplied.

Create (SourceType, SourceData, Version)

Dim pvtcacCreate As PivotCache
Set pvtcacCreate = ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation)

Arguments

The following argument is required

SourceType (XlPivotTableSourceType) - SourceType can be one of these XlPivotTableSourceType constants: xlConsolidation, xlDatabase, or xlExternal.


Possible Values are

xlConsolidation Multiple consolidation ranges.
xlDatabase Microsoft Excel list or database.
xlExternal Data from another application.
xlPivotTable Same source as another PivotTable report.
xlScenario Data is based on scenarios created using the Scenario Manager.

Optional arguments

The following arguments are optional

SourceData - The data for the new PivotTable cache

Version - Version of the PivotTable. Version can be one of the XlPivotTableVersionList constants

SourceData - The data for the new PivotTable cache

Version - Version of the PivotTable. Version can be one of the XlPivotTableVersionList constants