Here is code that does it. Place it in ThisWorkbook module.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
[Session_ended] = Now()
[Session_Duration] = [Session_ended] - [Session_started]
[Total_time] = [Total_time] + [Session_Duration]
[Session_started] = Now() ' start new session in case user keeps working
End Sub
Private Sub Workbook_Open()
[Session_started] = Now()
End Sub
In a new sheet, define these cells in A2:A5
Session started
Session ended
Session Duration
Total time
Use the Names deine tool to name the cells B2:B5 from teh left column (so matching te code in [brackets].
You can hide the sheet if you wish (as long as it's not the only one).
To see the value, either don't hide the timer sheet of place a forumla =[Total_time} somewhere/
Voila!
Bookmarks