W
What-A-Tool
I place a time value in a cell - this time value is user selected from a
DateTime picker control on a form.
When I retrieve this time from the cell, it comes back as a decimal value.
It's driving me nuts - I can't see what I'm doing stupid here - can someone
please shed some light on this ?
dtpDayStart - Format: dtpCustom CustomFormat: h:mm tt
Cell A3 - Format: Time Type: 13:30
Save to cell : ----------------------------------------------
Dim vntStrt As Variant
vntStrt = Split(Format(dtpDayStart.Value, "hh:mm"), ":")
Worksheets("UserData").Range("A3").Value = _
vntStrt(0) & ":" & RoundToQuarterHour(vntStrt(1))
<<vntStrt(0) & ":" & RoundToQuarterHour(vntStrt(1))>> "This is
saving a value of 07:00 to cell A3"
The value as viewed in the Excel InsertFunction bar
is 7:00:00 AM, viewed in the cell as 7:00
Read from cell : ---------------------------------------------
Dim dtmDayStrt As Date
dtmDayStrt = Worksheets("UserData").Range("A3").Value
<<dtmDayStrt = Worksheets("UserData").Range("A3").Value>> "This
is returning a value of 0.291666666666667"
This same value is retrieved even if I save
dtpDayStart.Value directly to the cell, so its not a result of the way I'm
concatenating it.
The strange thing is, I am saving a time value into cell B3 as well, using
the exact same code to read and write as above for A3, and yet it reads this
as a time, just as I expect. @#$%%^!!
I have manually formatted A3 as time, then I have used the formatpainter to
make A3 the same as B3, all with the same result.
Thanks for any help -
Sean
DateTime picker control on a form.
When I retrieve this time from the cell, it comes back as a decimal value.
It's driving me nuts - I can't see what I'm doing stupid here - can someone
please shed some light on this ?
dtpDayStart - Format: dtpCustom CustomFormat: h:mm tt
Cell A3 - Format: Time Type: 13:30
Save to cell : ----------------------------------------------
Dim vntStrt As Variant
vntStrt = Split(Format(dtpDayStart.Value, "hh:mm"), ":")
Worksheets("UserData").Range("A3").Value = _
vntStrt(0) & ":" & RoundToQuarterHour(vntStrt(1))
<<vntStrt(0) & ":" & RoundToQuarterHour(vntStrt(1))>> "This is
saving a value of 07:00 to cell A3"
The value as viewed in the Excel InsertFunction bar
is 7:00:00 AM, viewed in the cell as 7:00
Read from cell : ---------------------------------------------
Dim dtmDayStrt As Date
dtmDayStrt = Worksheets("UserData").Range("A3").Value
<<dtmDayStrt = Worksheets("UserData").Range("A3").Value>> "This
is returning a value of 0.291666666666667"
This same value is retrieved even if I save
dtpDayStart.Value directly to the cell, so its not a result of the way I'm
concatenating it.
The strange thing is, I am saving a time value into cell B3 as well, using
the exact same code to read and write as above for A3, and yet it reads this
as a time, just as I expect. @#$%%^!!
I have manually formatted A3 as time, then I have used the formatpainter to
make A3 the same as B3, all with the same result.
Thanks for any help -
Sean