Dim blnClockRunning As Boolean Sub startclock() 'assign start button blnClockRunning = True clock End Sub Sub clock() If blnClockRunning = False Then Exit Sub ActiveWorkbook.Worksheets(1).Cells(1, 1).Value = Format(Now, "hh:mm:ss") Application.OnTime (Now + TimeSerial(0, 0, 1)), "Sheet1.clock" End Sub Sub stopclock() 'assign stop button blnClockRunning = False End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address(True, True, xlA1) = "$B$1" Then Range("B1") = "Start" Range("B1").Select Selection.Font.FontStyle = "Bold" Selection.Font.ColorIndex = 2 ' White Selection.Interior.ColorIndex = 1 ' Black Call startclock End If If Target.Address(True, True, xlA1) = "$C$1" Then Range("C1") = "Stop" Range("C1").Select Selection.Font.FontStyle = "Bold" Selection.Font.ColorIndex = 2 ' White Selection.Interior.ColorIndex = 1 ' Black Call stopclock End If End Sub |