Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default DataType Property

The Excel HELP file demonstrates how to test for data types in a PivotTABLE:

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

How do I test for DataTypes in a cell in a regular worksheet (my crude
attempts are)

msgbox ActiveCell.DataType
msgbox Range("A1").DataType

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default DataType Property

vartype(activecell)

See help on Vartype for the constant values returned.

--
Regards,
Tom Ogilvy


"Access101" wrote in message
...
The Excel HELP file demonstrates how to test for data types in a

PivotTABLE:

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

How do I test for DataTypes in a cell in a regular worksheet (my crude
attempts are)

msgbox ActiveCell.DataType
msgbox Range("A1").DataType



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default DataType Property

Thanks for you help. I was hoping to be able to test for these DataTypes:

'xlParamTypeBinary
'xlParamTypeChar
'xlParamTypeDecimal
'xlParamTypeFloat
'xlParamTypeLongVarBinary
'xlParamTypeNumeric
'xlParamTypeSmallInt
'xlParamTypeTimestamp
'xlParamTypeUnknown
'xlParamTypeVarChar
'xlParamTypeBigInt
'xlParamTypeBit
'xlParamTypeDate
'xlParamTypeDouble
'xlParamTypeInteger
'xlParamTypeLongVarChar
'xlParamTypeReal
'xlParamTypeTime
'xlParamTypeTinyInt
'xlParamTypeVarBinary
'xlParamTypeWChar

"Tom Ogilvy" wrote:

vartype(activecell)

See help on Vartype for the constant values returned.

--
Regards,
Tom Ogilvy


"Access101" wrote in message
...
The Excel HELP file demonstrates how to test for data types in a

PivotTABLE:

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

How do I test for DataTypes in a cell in a regular worksheet (my crude
attempts are)

msgbox ActiveCell.DataType
msgbox Range("A1").DataType




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default DataType Property

Numbers are stored as double

If the number is formatted as currency, then it would return currency

if the number is formatted as a date, then it would return a date

then you have string, error and empty.

All the constants that don't fit in that, you would ignore.

Reference your posted sub:

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"

--
Regards,
Tom Ogilvy



"Access101" wrote in message
...
Thanks for you help. I was hoping to be able to test for these DataTypes:

'xlParamTypeBinary
'xlParamTypeChar
'xlParamTypeDecimal
'xlParamTypeFloat
'xlParamTypeLongVarBinary
'xlParamTypeNumeric
'xlParamTypeSmallInt
'xlParamTypeTimestamp
'xlParamTypeUnknown
'xlParamTypeVarChar
'xlParamTypeBigInt
'xlParamTypeBit
'xlParamTypeDate
'xlParamTypeDouble
'xlParamTypeInteger
'xlParamTypeLongVarChar
'xlParamTypeReal
'xlParamTypeTime
'xlParamTypeTinyInt
'xlParamTypeVarBinary
'xlParamTypeWChar

"Tom Ogilvy" wrote:

vartype(activecell)

See help on Vartype for the constant values returned.

--
Regards,
Tom Ogilvy


"Access101" wrote in message
...
The Excel HELP file demonstrates how to test for data types in a

PivotTABLE:

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

How do I test for DataTypes in a cell in a regular worksheet (my crude
attempts are)

msgbox ActiveCell.DataType
msgbox Range("A1").DataType






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save as a dbf file changes datatype araki Excel Discussion (Misc queries) 0 November 18th 05 10:42 PM
listbox default datatype grinning_crow[_6_] Excel Programming 0 September 1st 04 11:58 AM
need help- SUB: DATATYPE FOR A CELL.. monika Excel Programming 1 February 13th 04 02:13 PM
DataType Conversion AsimKhaliq Excel Programming 0 January 21st 04 12:40 AM
How do I change the datatype of a cell? Casper Hornstrup Excel Programming 5 December 10th 03 01:46 PM


All times are GMT +1. The time now is 06:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"