Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Determining the data type.

Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Determining the data type.

To an extent, yes

=CELL("format",A1)

If the Microsoft Excel format is CELL returns
General "G"
0 "F0"
#,##0 ",0"
0.00 "F2"
#,##0.00 ",2"
$#,##0_);($#,##0) "C0"
$#,##0_);[Red]($#,##0) "C0-"
$#,##0.00_);($#,##0.00) "C2"
$#,##0.00_);[Red]($#,##0.00) "C2-"
0% "P0"
0.00% "P2"
0.00E+00 "S2"
# ?/? or # ??/?? "G"
m/d/yy or m/d/yy h:mm or mm/dd/yy "D4"
d-mmm-yy or dd-mmm-yy "D1"
d-mmm or dd-mmm "D2"
mmm-yy "D3"
mm/dd "D5"
h:mm AM/PM "D7"
h:mm:ss AM/PM "D6"
h:mm "D9"
h:mm:ss "D8"


--
__________________________________
HTH

Bob

"satadru" wrote in message
...
Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Determining the data type.

You should be able to construct your own code built around the code concepts
in this macro...

Sub WhatIsIt()
With ActiveCell
If IsDate(.Value) Then
MsgBox "It's a date!"
ElseIf WorksheetFunction.IsNumber(.Value) Then
MsgBox "Excel thinks you have a number of some sort."
Else
MsgBox "It looks like text to me."
End If
End With
End Sub

--
Rick (MVP - Excel)


"satadru" wrote in message
...
Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Determining the data type.

Dear All,

I found a solution which solves a part of my problem. The solution is to use
the TYPE(cell reference) function.

If value is TYPE returns
Number 1
Text 2
Logical value 4
Error value 16
Array 64

My problem starts again when I need to checkout on whether its a date field,
or if it contains a formula.

Many thanks in advance.
"satadru" wrote:

Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Determining the data type.

Thanks to Bob and Rick. Your solutions are the ones which helped solve my
problem.

"satadru" wrote:

Dear All,

I found a solution which solves a part of my problem. The solution is to use
the TYPE(cell reference) function.

If value is TYPE returns
Number 1
Text 2
Logical value 4
Error value 16
Array 64

My problem starts again when I need to checkout on whether its a date field,
or if it contains a formula.

Many thanks in advance.
"satadru" wrote:

Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default Determining the data type.

Hi

Try this function, just notice, that TargetCell has to be a single cell:


Function CellNumberFormat(ByRef TargetCell As Range)
If TargetCell.Cells.Count 1 Then
CellNumberFormat = "#Range"
Exit Function
End If
f = TargetCell.NumberFormat
CellNumberFormat = f
End Function

Regards,
Per

"satadru" skrev i meddelelsen
...
Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Determining the data type.

Thanks Per for the solution offered.

"Per Jessen" wrote:

Hi

Try this function, just notice, that TargetCell has to be a single cell:


Function CellNumberFormat(ByRef TargetCell As Range)
If TargetCell.Cells.Count 1 Then
CellNumberFormat = "#Range"
Exit Function
End If
f = TargetCell.NumberFormat
CellNumberFormat = f
End Function

Regards,
Per

"satadru" skrev i meddelelsen
...
Dear All,
Without using the "Format -- Cells -- Number" option, is it possible to
determine the data type / format of a particular cell or a range of cells?

I am trying to look for a formula or a piece of code which could possibly
help me out in this.

Many thanks in advance.



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
Determining the text mode from a variety of data types matt3542 Excel Worksheet Functions 17 July 31st 08 08:01 PM
How can i filter data type in a cell? blauerhund Excel Discussion (Misc queries) 2 June 3rd 08 07:34 PM
Data Type Problem? bailey Excel Discussion (Misc queries) 8 December 6th 05 03:51 AM
Adding new 'Type' to Format->Number->Time->Type Chip Pearson Excel Discussion (Misc queries) 5 September 26th 05 08:45 PM
Need help determining Chart Type AlCamp Charts and Charting in Excel 10 March 19th 05 10:48 PM


All times are GMT +1. The time now is 04:06 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"