PivotTable.PivotValueCell method (Excel)

Retrieve the PivotValueCell object for a given PivotTable provided certain row and column indices.

Syntax

expression.PivotValueCell (RowLine, ColumnLine)

expression A variable that represents a PivotTable object.

Parameters

Name Required/Optional Data type Description
RowLine Optional Variant If of type PivotLine, specifies the PivotLine in the row area that the PivotValueCell is aligned with. If of type Int, specifies the position of the PivotLine on the row area that the PivotValueCell is aligned with. If missing, Empty, Null, or 0 specifies the grand total row.
ColumnLine Optional Variant If of type PivotLine, specifies the PivotLine in the column area that the PivotValueCell is aligned with. If of type Int, specifies the position of the PivotLine on the column area that the PivotValueCell is aligned with. If missing, Empty, Null or 0 specifies the grand total column.

Return value

PIVOTVALUECELL

Example

This code sample uses the PivotValueCell property to test whether the value of one cell in a PivotTable is greater than the value of another cell.

Sub TestEquality()
Dim X As Double
Dim Y As Double

'This code assumes you have a Standalone PivotChart on one of the worksheets
X = ThisWorkbook.PivotTables(1).PivotValueCell(1, 1).Value
Y = ThisWorkbook.PivotTables(1).PivotValueCell(1, 2).Value

If X > Y Then
MsgBox "X is greater than Y"
Else
MsgBox "Y is greater than X"
End If
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.