Time Keep in excel sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I calculate the amount of time a user spents on a sheet, and when he closes the sheet, the timer will store the total amount of time spent in another excel sheet? Thanx.
 
One way... behind the sheet you wish to record the time the user is on this
sheet, put the following code, when the sheet is activated the start time is
stored, when deactivated the difference is recorded in Sheet 2 cell A1 -
format this cell as Time. This will only record the last activate-deactivate
event. I hope this provides a useful template.

Option Explicit
Public StartTime As Date
Public UserTime As Date

Private Sub Worksheet_Activate()
StartTime = Now
End Sub

Private Sub Worksheet_Deactivate()
UserTime = Now - StartTime
Worksheets(2).Range("A1").Value = UserTime
End Sub


Cheers
Nigel

Ben said:
How do I calculate the amount of time a user spents on a sheet, and when
he closes the sheet, the timer will store the total amount of time spent in
another excel sheet? Thanx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top