ThisWorkbook
[vba]
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Sheets(1).Range("C1").Value = TimeValue("00:15:00")
Application.OnTime nexttick, "UpdateClock", schedule:=False
ActiveWorkbook.Sheets(1).Range("A5").ClearContents
ActiveWorkbook.Save
End Sub
Private Sub Workbook_Open()
Call UpdateClock
Call test
End Sub
[/vba]
Standard
[vba]
Public nexttick As Double
Public Sub UpdateClock()
' Updates the clock that's visible
' DIGITAL CLOCK
With ThisWorkbook.Sheets(1)
.Range("A5").Value = CDbl(Time)
.Range("A5").NumberFormat = "hh:mm:ss"
.Range("C1").Value = .Range("C1").Value - TimeValue("00:00:01")
If .Range("C1").Value <= 0 Then
ThisWorkbook.Close savechanges:=False
End If
End With
' Set up the next event one second from now
nexttick = Now + TimeValue("00:00:01")
Application.OnTime nexttick, "UpdateClock"
End Sub
[/vba]