I have a start stop time button excel 2010 sheet to keep track of how much I spend on tasks at work. It was working fine until this morning and I am getting a Run-time Error 424 Message. The code is below. Any help you can give will be greatly appreciated!!
Option Explicit
Private Sub btnStart_Click()
ActiveSheet.Unprotect
Cells(Rows.Count, 5).End(xlUp).Offset(1) = Date
Cells(Rows.Count, 6).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 7).End(xlUp).NumberFormat = "hh:mm"
Cells(Rows.Count, 8).End(xlUp).Offset(1) = Environ("username")
Me.btnStart.Enabled = False
Me.btnStop.Enabled = True
End Sub
Private Sub btnStop_Click()
ActiveSheet.Unprotect
Cells(Rows.Count, 7).End(xlUp).Offset(1) = Now
Cells(Rows.Count, 7).End(xlUp).NumberFormat = "hh:mm"
Me.btnStart.Enabled = True
Me.btnStop.Enabled = False
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
Public RunWhen As Double
Public Const cRunIntervalSeconds = 10 ' 10 seconds
Public Const cRunWhat = "The_Sub" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True
End Sub
Sub The_Sub()
[a1] = Now
' Call StartTimer to schedule the procedure again
StartTimer
End Sub
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…