M
Mike B.
When I changed from "Sheet1" when clock was running, clock appeared in the
"Sheet2" as well in that specific cell and gave me hourglass cursor so I
couldn't go back to the orignial sheet. Is there anyway to overcome this? I
plan to switch between other sheets while the clock is running to input data
that will stop the clock.
This is the code written in the sheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
mPrev = Me.Range(WS_RANGE).Value
End Sub
Private Sub Worksheet_Calculate()
On Error GoTo ws_exit
Application.EnableEvents = False
If Me.Range(WS_RANGE).Value <> mPrev Then
With Me.Range(WS_RANGE)
If .Value = 1 Then
nCount1 = 60
Call RunTimer
ElseIf .Value = 0 Then
nCount1 = 0
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
This is code written in the module:
Public nCount1 As Long
Public Sub RunTimer()
If nCount1 >= 0 Then
Range("W11") = nCount1
nCount1 = nCount1 - 1
Application.OnTime Now + TimeSerial(0, 0, 1), "RunTimer"
End If
End Sub
"Sheet2" as well in that specific cell and gave me hourglass cursor so I
couldn't go back to the orignial sheet. Is there anyway to overcome this? I
plan to switch between other sheets while the clock is running to input data
that will stop the clock.
This is the code written in the sheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
mPrev = Me.Range(WS_RANGE).Value
End Sub
Private Sub Worksheet_Calculate()
On Error GoTo ws_exit
Application.EnableEvents = False
If Me.Range(WS_RANGE).Value <> mPrev Then
With Me.Range(WS_RANGE)
If .Value = 1 Then
nCount1 = 60
Call RunTimer
ElseIf .Value = 0 Then
nCount1 = 0
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
This is code written in the module:
Public nCount1 As Long
Public Sub RunTimer()
If nCount1 >= 0 Then
Range("W11") = nCount1
nCount1 = nCount1 - 1
Application.OnTime Now + TimeSerial(0, 0, 1), "RunTimer"
End If
End Sub