Help with text box and time

  • Thread starter Thread starter D.S.
  • Start date Start date
D

D.S.

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.
 
Try this format option

txtTime = Format(Sheets("WRITEFORMDATA").Range("B22").Value, "HH:m"
 
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.



Try this format option

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