Gruppe
Ereignis
Problem
Wie kann ich mir in einer Zelle die aktuell verbrachte Tagesarbeitszeit anzeigen lassen?
ClassModule: DieseArbeitsmappe
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopClock
End Sub
Private Sub Workbook_Open()
Call StartClock
End Sub
StandardModule: basMain
Public Const gsMacro As String = "UpdateClock"
Public gdNextTime As Double
Sub PauseStart()
Dim iRow As Integer
iRow = Cells(Rows.Count, 2).End(xlUp).Row + 1
Cells(iRow, 2) = Now()
End Sub
Sub PauseEnde()
Dim iRow As Integer
iRow = Cells(Rows.Count, 3).End(xlUp).Row + 1
Cells(iRow, 3) = Now()
End Sub
Sub StartClock()
gdNextTime = Now + TimeSerial(0, 1, 0)
Application.OnTime earliesttime:=gdNextTime, _
procedure:=gsMacro, schedule:=True
End Sub
Sub UpdateClock()
ThisWorkbook.Worksheets("Arbeitszeit").Range("D3").Calculate
Call StartClock
End Sub
Sub StopClock()
On Error Resume Next
Application.OnTime earliesttime:=gdNextTime, _
procedure:=gsMacro, schedule:=False
End Sub