Stopwatch is greying out undo

Martina Hawkins

New Member
Joined
Aug 24, 2018
Messages
2
Hi, I have a stopwatch which is working great except when a user opens a new workbook the undo function is unavailable. It becomes available again when the clock is stopped.
I have the code below in a module. Does this happen to anyone else?
Option Explicit

Dim NextTick As Date, t As Date, PreviousTimerValue As Date

Private Sub StartTime()
PreviousTimerValue = Calculations.Range("A1").Value
t = Time
Call ExcelStopWatch
End Sub

Private Sub ExcelStopWatch()
Calculations.Range("A1").Value = Format(Time - t + PreviousTimerValue, "hh:mm:ss")
NextTick = Now + TimeValue("00:00:01")

If Calculations.Range("A1").Value > Calculations.Range("B3") Then
With Sheet4.Shapes("TimeBox")
.Fill.ForeColor.RGB = RGB(0, 255, 0)
End With

End If

Application.OnTime NextTick, "ExcelStopWatch"
End Sub

Sub StopClock()
On Error Resume Next
Application.OnTime earliesttime:=NextTick, procedure:="ExcelStopWatch", schedule:=False
With Sheet4.Shapes("TimeBox")
.Fill.ForeColor.RGB = RGB(255, 0, 0)
End With
End Sub

Sub Reset()
On Error Resume Next

With Sheet4.Shapes("TimeBox")
.Fill.ForeColor.RGB = RGB(192, 192, 192)
End With

Application.OnTime earliesttime:=NextTick, procedure:="ExcelStopWatch", schedule:=False
Calculations.Range("A1").Value = 0
End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I've found the problem but not the solution. If I don't colour the shape it works. Has anyone a solution as to how to colour a shape not using vba.
Trying to use conditional formatting but can't get it figured out.

'If Calculations.Range("A1").Value > Calculations.Range("B3") Then

' With Sheet4.Shapes("TimeBox")
' .Fill.ForeColor.RGB = RGB(0, 255, 0)
' End With

'End If
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top