Name
pivottable.GetPivotData([DataField], [Field1], [Item1], [Fieldn], [Itemn])
Synopsis
Returns the Range object containing the items described by the method arguments.
|
Argument |
Settings |
|---|---|
|
|
The name of the data field within which to get the range |
|
|
The name of the page, row, or column field within which to get the range |
|
|
The value to look up within the page, column, or row specified by |
|
|
Additional field and value pairs that define the data value range to retrieve |
If you omit all arguments, GetPivotData returns the Range object for the cell containing the grand total for the pivot table. If GetPivotData can’t find the item using the criteria in the arguments, an error occurs.
The following code gets a value from the pivot table created earlier (see Figure 13-7 for an illustration of the pivot table):
Sub GetPivotTableData2( )
Dim pt As PivotTable
' Run CreatePivotTable to create this pivot table.
Set pt = ActiveSheet.PivotTables(1)
' Display data in Immediate window.
Debug.Print pt.GetPivotData("SalesRank", "ProductName", _
"Essential SharePoint", _
"Date", #11/3/2005 9:02:56 AM#).Value
End SubBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access