Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maybe simple? excel VBA TIME

Status
Not open for further replies.

instanceoftime

Technical User
Mar 16, 2011
7
US
cell B2 has a time (24hr) 8:23:28 in it.

I want to copy this time into txtbxTime

I tried:

Me.txtbxTime.ControlSource = ("B" & 2)

but the time 8:23:28 is looking like

0.34962962962963

How can I do this?
 


Code:
Me.txtbxTime.ControlSource = Format(Worksheets("YourSheetName").Cells(2, "B"),"hh:mm:ss")

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
A simple CDate should suffice, and display in selected regiona format ...
 
Still ran into problems with the above code... so I

Dim vTime As Date

vTime = Range("B2").Value
Me.txtbxTime = vTime

and it worked

but thanks for your help guys... I'm sure I will be back soon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top