DataType Property

Microsoft Excel Visual Basic

Returns or sets the data type of the specified query parameter. Read/write XlParameterDataType.

XlParameterDataType can be one of these XlParameterDataType constants.
xlParamTypeBinary
xlParamTypeChar
xlParamTypeDecimal
xlParamTypeFloat
xlParamTypeLongVarBinary
xlParamTypeNumeric
xlParamTypeSmallInt
xlParamTypeTimestamp
xlParamTypeUnknown
xlParamTypeVarChar
xlParamTypeBigInt
xlParamTypeBit
xlParamTypeDate
xlParamTypeDouble
xlParamTypeInteger
xlParamTypeLongVarChar
xlParamTypeReal
xlParamTypeTime
xlParamTypeTinyInt
xlParamTypeVarBinary
xlParamTypeWChar

expression.DataType

expression    Required. An expression that returns one of the above objects.

ShowDataType property as it applies to the PivotField object.

Returns a constant describing the type of data in the PivotTable field. Read-only XlPivotFieldDataType.

XlPivotFieldDataType can be one of these XlPivotFieldDataType constants.
xlDate
xlNumber
xlText

expression.DataType

expression    Required. An expression that returns one of the above objects.

Example

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

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