Hey Guys, I added the tweaks from Kenneths code and I think it fixed the bug. There are some extra procedures in the module code that are from a logsheet SamT helped create. Anyway I think its working so don't want to change it but if it breaks i'll try some of the other suggestions. Thanks Guys! My boss thinks Im super smart (=
In a module.
Const LogSheet As String = "Log"Const BaseCol As String = "B"
Public DownTime As Date
Sub SetTimer()
DownTime = Now + TimeValue("00:10:05")
Application.OnTime EarliestTime:=DownTime, _
Procedure:="Notify", Schedule:=True
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=DownTime, _
Procedure:="Notify", Schedule:=False
End Sub
Sub Notify()
With ThisWorkbook
If Len(ThisWorkbook.Sheets("Log").Range("B2")) > 0 Then
MsgBox "Deactivated"
Sheets(LogSheet).Cells(Rows.Count, BaseCol).End(xlUp).Offset(0, 1).Value = Now
Application.StatusBar = "Off The Clock"
End If
MSG1 = MsgBox("You Are Still Recording Time Recording Time For " & ThisWorkbook.Name, vbOKOnly)
If MSG1 = vbOK Then
MsgBox "Activated"
Sheets(LogSheet).Cells(Rows.Count, BaseCol).End(xlUp).Offset(1, 0).Value = Now
Application.StatusBar = "On The Clock"
End If
End With
End Sub
In 'ThisWorkbook'
Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
StopTimer
SetTimer
End Sub
Private Sub Workbook_WindowDeactivate(ByVal Wn As Excel.Window)
StopTimer
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
StopTimer
SetTimer
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
StopTimer
SetTimer
End Sub