#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default type check


how can i know a value of specific cell is time or not using macro?

by the way, vartype(cel) ??
then number or time all result = 5
i want to get a time cell only.

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default type check


Dim v as variant, s as string

v = cell.value

VarType(v)

time, a decimal between 0-1 : returns 5 / vbDouble
date, integer : returns 7 / vbDate
date and time, decimal greater than 1 : returns 7 / vbDate

s = activecell.numberformat

So if you have a double between 0-1, and the numberformat includes
characters associated with time format, eg "h", there's a strong possibility
you've got a time. But not conclusive.

Regards,
Peter T

"x taol" wrote in message
...

how can i know a value of specific cell is time or not using macro?

by the way, vartype(cel) ??
then number or time all result = 5
i want to get a time cell only.

*** Sent via Developersdex http://www.developersdex.com ***



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
check spelling as you type dp New Users to Excel 5 February 3rd 10 07:00 PM
Check for error.type in same cell art Excel Worksheet Functions 2 May 13th 09 06:14 AM
how to check that a var type date is initialized ?? François Excel Programming 3 July 16th 05 07:15 PM
userform-check data type xlcharlie Excel Programming 3 March 28th 05 03:11 PM
How to check a Variant for its data type TBA[_2_] Excel Programming 5 January 9th 04 11:04 PM


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