So I have a code below that when you double click a cell in Column C, it will perform a stopwatch in Column D and E and what you double click on any other cell besides column c, the time expires. I need to lock that from there protecting it with a password so nobody can change the log time as people might change it. It should get precisely the amount of time spent for a particular process. so when i double click on a different cell to stop the time, can the cells in column d and f be locked?
And how can I lock the module for this too so that nobody can mess up with the code?
And how can I lock the module for this too so that nobody can mess up with the code?
Rich (BB code):
Rich (BB code):
Public stopMe As Boolean
Public resetMe As Boolean
Public myVal As Variant
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 3 Then
If Target.Value = myVal And Target.Value <> "" Then
'Changed
Dim startTime, finishTime, totalTime, timeRow
startTime = Timer
stopMe = False
resetMe = False
myTime = Target.Offset(, 4).Value
Target.Offset(, 3).Select
startMe:
DoEvents
timeRow = Target.Row
finishTime = Timer
totalTime = finishTime - startTime
Target.Offset(, 1).Value = Format(myTime + totalTime, "00.00")
If resetMe = True Then
Target.Offset(, 3).Value = 0
Target.Offset(, 4).Value = 0
stopMe = True
End If
If Not stopMe = True Then
Target.Offset(, 2).Value = totalTime
GoTo startMe
End If
Cancel = True
End
Else
'Not Changed
stopMe = True
Cancel = True
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
myVal = Target.Value
End Sub