Cumulative Time Usage in a Worksheet

C

Charles1732

Does anyone know how to build a time clock into a worksheet that will track
the cumulative time the worksheet is used for each opening and closing of the
worksheet?
 
B

Bob Phillips

Create a Public variable called nTime in a standard code module, and add
this code to your workbook

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Worksheets("Sheet1").Range("a1")
.Value = .Value + (Now - nTime)
End With
End Sub

Private Sub Workbook_Open()
nTime = Now
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
 
Top