Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Determine number format of excel cell

hi,

I am writing a program to read data from excel sheet.
while reading a cell which contains a date, it returns a number.

Eg:Suppose cell A1 contains the following date : February 13, 1900
The Range object that refers the cell, returns to me 44 as value.

By googling, I found the method to convert it back to the date format.
they are : Application.WorksheetFunction.Text(value, "mm/dd/yyyy")
or DateTime.FromOADate(double d)


But my question, is there any way i can determine if the cell has DATE
type.

I can get the format of the date by using Range.NumberFormat. But I
need to first know, if the cell is DATE type for that?

Any help would be appreciated.

Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Determine number format of excel cell

Why not read the .Text property instead of the .Value property of the range.

Or
Public Function GetVarType(InputCell As Range) As Long
'Check the help for the meaning of the return values
'But a Date will return # 7
GetVarType = VarType(InputCell.Value)
End Function

NickHK

"James Bond" wrote in message
oups.com...
hi,

I am writing a program to read data from excel sheet.
while reading a cell which contains a date, it returns a number.

Eg:Suppose cell A1 contains the following date : February 13, 1900
The Range object that refers the cell, returns to me 44 as value.

By googling, I found the method to convert it back to the date format.
they are : Application.WorksheetFunction.Text(value, "mm/dd/yyyy")
or DateTime.FromOADate(double d)


But my question, is there any way i can determine if the cell has DATE
type.

I can get the format of the date by using Range.NumberFormat. But I
need to first know, if the cell is DATE type for that?

Any help would be appreciated.

Thank you.



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
sumproduct, multiple if, some same cell, determine number of rows Tim Excel Worksheet Functions 4 March 26th 09 08:57 AM
How to determine the cell contain number only? Eric Excel Discussion (Misc queries) 1 July 2nd 07 09:28 AM
How do I determine the number of cell formats in this workbook tucsonmissiledude Excel Discussion (Misc queries) 2 October 28th 05 05:59 AM
Determine number of lines of text within a cell Andibevan[_4_] Excel Programming 2 August 26th 05 03:09 PM
HOW-TO: Determine if a cell contains a number vs. formula vs. reference List Lurker Excel Programming 4 October 11th 04 05:48 AM


All times are GMT +1. The time now is 01:29 AM.

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"