Timer

jadrace

New Member
Joined
Jan 11, 2012
Messages
12
Hi,
I have a timer function that counts down, however I need to add a pause button and function.
Can anybody advise on the code to pause the count down.
the code for my timer is:-
Sub Makechange()
Dim PauseTime, Start
Do
PauseTime = 1 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Sheet1.Range("E13").Value = Now()

Loop

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi
The timer is to give me a count down for a race diatance / time, however sometimes when there is an accident the stop the race, then continue it later.
Hence I need a function to pause the times, and then continue the counter again.
Gary
 
Upvote 0
Hi Gary

Check this out... First run Mmacro. It will stop on the 50th iteration. You can resume by running Rresume.

Code:
Public Sub Mmacro()
    Dim i
    
    For i = 1 To 100
        If i = 50 Then Stop
        Debug.Print i
    Next i
End Sub

Public Sub Rresume()
    Resume
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

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