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
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

jadrace

New Member
Joined
Jan 11, 2012
Messages
12
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
 

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,808
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,205
Messages
5,623,363
Members
415,969
Latest member
Rey99

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
Top