On 2002-10-25 17:45, Yogi wrote:
Richie,
It works great! Thanks!
Is there any way I could write the macro to display the "25" seconds before the button is pushed starting the countdown and then after the countdown is completed it goes back to displaying the "25" seconds until the button is pushed again?
Thanks again.
Just change to the following:
<pre/>
Sub CountDown()
Dim pausetime As Single
Dim start As Single
Dim finish As Single
Dim totaltime As Single
pausetime = 25 ' Set duration.
start = Timer ' Set start time.
Sheets(1).Range("B2").Value = 25
Do While Timer < start + pausetime
DoEvents ' Yield to other processes.
Sheets(1).Range("B2").Value = _
Format(pausetime + (start - Timer), "##")
Loop
Sheets(1).Range("B2").Value = 25
End Sub
</pre>
Note: Whilst Do Events yields to other processes you will notice 2 things;
1) There is a flicker
2) Editing cells will stop the operating macro.
There are a number of ways to over come this;
1) Use an ActiveX control timer
2) Use an Ontile call
3) Use some API calls to the winmm dll