Help with text box and time

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.
 
K

Kieran

Try this format option

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

D.S.

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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top