An active clock

Status
Not open for further replies.

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
893
The following code gives the actual time (every second adapting) in cell A47 when macro SetTime is run. What shows up is this format "15-5-2003 14:48:25". What I want is only the time format "14:48:25". Changing the cell properties does not make a change. Who can help?

Dim SchedRecalc As Date

Sub SetTime()
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "Recalc"
End Sub

Sub Recalc()
Range("A47").Value = Now

Call SetTime
End Sub

Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Change this to Time. Now puts the full date/time combination, where Time will only place the actual time.

Code:
Range("A47").Value = Time
 
Upvote 0
Thanks POME for the fast reply. It does work!

May I ask you another question? A label in a form is linked to this cell "A47". The label however is static; the time does not count up. The code in the label is as follows:

Private Sub Label3_Click()

End Sub

Private Sub UserForm_Initialize()
Label3 = Sheets("Dagteller").Range("A50").Text
End Sub

What code is needed that the form gets 'updated" every second?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,221,691
Messages
6,161,322
Members
451,696
Latest member
Senthil Murugan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top