PivotField.DataType Property

Excel Developer Reference

Returns a XlPivotFieldDataType value that represents the type of data in the PivotTable field.

Syntax

expression.DataType

expression   A variable that represents a PivotField object.

Example

This example displays the data type of the field named "ORDER_DATE."

Visual Basic for Applications
  Set pvtTable = Worksheets("Sheet1").Range("A3").PivotTable
Select Case pvtTable.PivotFields("ORDER_DATE").DataType
    Case Is = xlText
        MsgBox "The field contains text data"
    Case Is = xlNumber
        MsgBox "The field contains numeric data"
    Case Is = xlDate
        MsgBox "The field contains date data"
End Select

See Also