ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with text box and time (https://www.excelbanter.com/excel-programming/283408-help-text-box-time.html)

D.S.[_3_]

Help with text box and time
 
My procedure records the system time in a worksheet cell (formatted as "time"), and at the same time, writes to a userform textbox the system time.

On userform activation, it will write recorded data from the spreadsheet to the userform.

The problem is, the time that was recorded on the userform, now shows as a decimal number, rather than the actual time displayed in the worksheet cell.

This is the line that writes to the spreadsheet, which results in <10:37 PM
Sheets("writeformdata").Range("B22").Value = Time

This line writes to userform upon activation, which results in <0.942615740740741
txtTime = Sheets("WRITEFORMDATA").Range("B22").Value

What's going on here?

D.S.




Kieran[_2_]

Help with text box and time
 

Try this format option

txtTime = Format(Sheets("WRITEFORMDATA").Range("B22").Value, "HH:m"

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com


D.S.[_3_]

Help with text box and time
 
Thanks Kieran,
that got me on the right track. The following code gave me the result I was looking for
txtTime = Format(Sheets("WRITEFORMDATA").Range("B22").Value, "HH:MM AMPM")


D.S.


"Kieran" wrote in message ...

Try this format option

txtTime = Format(Sheets("WRITEFORMDATA").Range("B22").Value, "HH:m")


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com