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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I find and display the current time in a cell? 1

Status
Not open for further replies.

JensKKK

Technical User
May 8, 2007
119
GB
Hi,

I used the two lines of code to display the data in a form.

And I want to display the current time as well. How can I do that?

Thanks for reading til here.

Sheets("my Sheet").Cells(130, 22).value = Date
Label6.Caption = Sheets("my Sheet").Cells(130, 22)
 
= time

gets you the time

= now

gets you the date and time in one shot.

 




Hi,

Since Date/Time values are NUMBERS, when you want to display a Date or Time format, you have to do something extra.

Happens that Excel usually figures out that you have a Date or Time in a CELL, but not in a control. Here, you must use the Format function to return a STRING in the format of your choosing...
Code:
Sheets("my Sheet").Cells(130, 22).value = Now
Label6.Caption = Format(Sheets("my Sheet").Cells(130, 22),"hh:nn"ss")

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top