PivotValueCell Object (Excel)

Office 2013

Provides a way to expose values of cells in the case that actual cells (Range objects) are not available.

Version Added: Excel 2013

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

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

'This code assumes that 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
Show:
© 2014 Microsoft