Create method takes three arguments, of which only one (SourceType) is
required. The SourceData argument is required when SourceType does not equal xlExternal.
Table 6-1 lists the PivotCaches.Create method??™s arguments and describes them.
Table 6-1. PivotCaches.Create Method Arguments
Name Required (Y/N) Data Type Description
SourceType Y xlPivotTableSourceType Choices are xlConsolidation,
xlDatabase, or xlExternal
SourceData N Variant The data for the new PivotTable
cache
Version N Variant Version of the PivotTable
The PivotCaches.Create method returns a PivotCache object. The Macro Recorder very
cleverly calls the CreatePivotTable method based on the return from the Create method in
one long (but readable) line of code:
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= ??
"Sheet1!R1C1:R43C6", Version:=xlPivotTableVersion12).CreatePivotTable ??
TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion ??
:=xlPivotTableVersion12
CHAPTER 6 n PIVOTTABLES 230
The CreatePivotTable method defines where the table will be placed, its name, and its
default version. Table 6-2 lists the CreatePivotTable method??™s arguments.
Table 6-2. CreatePivotTable Method Arguments
Name Required (Y/N) Data Type Description
TableDestination Y Variant The cell in the top-left corner of the
PivotTable??™s destination range.
TableName N Variant The name of the PivotTable report.
ReadData N Variant Set to True to create a PivotTable cache that
contains all of the records from the data
source (can be very large).
Pages:
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224