Using the above method, InStr will return a "3" because you are asking it for the position of the first colon in the string.
This is assuming of course that your time stamp follows the same format as the VB [tt]Time[/tt] Function.
Is this what you are trying to do?
[tt]"Very funny, Scotty... Now Beam down my clothes."[/tt]
Just a thought, but perhaps it's the type of content. Your active cell may contain a datestamp, but instr uses a string inside of a string. Perhaps try using this:
Dim Ti As Variant
Dim C As Integer
Ti = ActiveCell.Value()
C = Instr(1, Str(Ti), ":", 1)
MsgBox (C)
Maybe forcing it into a string form will fix your problem. I haven't tested the solution, so let us know if it works.
After thinking about it (after Jag and I posted at the same time), and looking at the situation some more. The Str function won't do what you are looking for. It requires a number, not a variant. Give THIS a try:
In Excel a Time value is stored as a Double representing the fraction of the day since midnight. If you use the formula =Now() in a cell it will give you a Date type. Otherwise any date value will be converted to a Double (unless you choose to format the cell otherwise)
If you really want to find the Colon position, use cdate function on the Double - that will however convert any Double into a Date (providing it's within the Date range) so you haven't gained much!
The overall answer is that Excel will always store a date as a double - it's only the format of the cell that determines how it appears
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
If this thread has been so educational and informative don't you think awarding some stars to the people who've helped you would be appropriate?
Unless, of course, two mouse clicks are way too much effort.
Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'People who live in windowed environments shouldn't cast pointers.'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.