Silver
09-07-2016, 01:25 PM
Below is a code for clock that I came across.
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long, TimerSeconds As Single, tim As Boolean
Dim Counter As Long
'~~> Start Timer
Sub StartTimer()
'~~ Set the timer for 1 second
TimerSeconds = 1
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
'~~> End Timer
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'~~> Update value in Sheet 1
Sheet1.Range("A1").Value = Time
End Sub
There are 2 buttons Start and End. When Start button is clicked the clock starts, and, stops
when End button is clicked.
I'm looking for below additions -
a) I want to setup the clock according to certain zones. Let's say I want to setup the clock
as per UK time, how do I go about doing it.
b) The code is stored in workbook "Time". So whenever workbook Time is opened the macro
should start.
c) In the afternoon macro should show time as 13:00, 14:00, 15:00 and so on instead of
01:00, 02:00, 03:00. After midnight macro should show time as 01:00, 02:00, 03:00 and
so on.
Have attached sample sheet.
Just an excel beginner. Any assistance will be appreciated
Public Declare Function SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long, TimerSeconds As Single, tim As Boolean
Dim Counter As Long
'~~> Start Timer
Sub StartTimer()
'~~ Set the timer for 1 second
TimerSeconds = 1
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
'~~> End Timer
Sub EndTimer()
On Error Resume Next
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
'~~> Update value in Sheet 1
Sheet1.Range("A1").Value = Time
End Sub
There are 2 buttons Start and End. When Start button is clicked the clock starts, and, stops
when End button is clicked.
I'm looking for below additions -
a) I want to setup the clock according to certain zones. Let's say I want to setup the clock
as per UK time, how do I go about doing it.
b) The code is stored in workbook "Time". So whenever workbook Time is opened the macro
should start.
c) In the afternoon macro should show time as 13:00, 14:00, 15:00 and so on instead of
01:00, 02:00, 03:00. After midnight macro should show time as 01:00, 02:00, 03:00 and
so on.
Have attached sample sheet.
Just an excel beginner. Any assistance will be appreciated