PivotValueCell.Value property (Excel)

Returns the value at the location. The value is the value after ShowAs and other calculations have been applied. Variant can be Empty, Number, Date, String, or Error value.

Syntax

expression.Value

expression A variable that represents a PivotValueCell object.

Remarks

This property works independently of whether the PivotTable is on a worksheet or not.

Property value

VARIANT

Example

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

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.