hi,
excel 2k
win 2k + xp
I have two timers sometimes running at the same time but one of them never resets the time in the cell I2 of my spreadsheet the way the other does. I want the time when started to show 0:00:00. Can anyone help?
Here is the code for both:
Code:
Option Explicit
Public RunWhen, RunWhen2 As Double
Public TimeStop, TimeStop2 As Double
Public Const cRunIntervalSeconds = 1 ' 1 second
Public Const cRunIntervalSeconds2 = 1 ' 1 second
Public Const cRunWhat = "The_Sub"
Public Const cRunWhat2 = "The_Sub2"
Public Const NAME = "MyDelayMacro"
Public Const NAME2 = "MyDelayMacro2"
Sub StartTimer()
On Error Resume Next
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, SCHEDULE:=True
End Sub
Sub The_Sub()
On Error Resume Next
Range("J2") = Format(Now - Range("H2"), "hh:mm:ss")
Range("J2").Font.Size = 20
Range("J2").Font.Bold = True
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, SCHEDULE:=False
Application.OnTime earliesttime:=Now, procedure:=NAME, SCHEDULE:=False
End Sub
Sub StartTimer2()
On Error Resume Next
RunWhen2 = Now + TimeSerial(0, 0, cRunIntervalSeconds2)
Application.OnTime earliesttime:=RunWhen2, procedure:=cRunWhat2, SCHEDULE:=True
End Sub
Sub The_Sub2()
On Error Resume Next
Range("I2") = Format(Now - Range("G2"), "hh:mm:ss")
Range("I2").Font.Size = 20
Range("I2").Interior.Color = vbRed
Range("I2").Font.Color = vbYellow
Range("I2").Font.Bold = True
Call StartTimer2
End Sub
Sub StopTimer2()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen2, procedure:=cRunWhat2, SCHEDULE:=False
Application.OnTime earliesttime:=Now, procedure:=NAME2, SCHEDULE:=False
End Sub