Revised Time Count-Down

Yogi

Board Regular
Joined
Oct 21, 2002
Messages
74
I want to be able to press a macro button that initiates a count down from 25-0 seconds in cell B2. Is this possible?
 
I was advise not to use a button but initiate the macro by clicking on the cell so I entered the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$BA$2" Then
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("BA2").Value = 25
Do While Timer< start + pausetime
DoEvents ' Yield to other processes.
Sheets(1).Range("BA2").Value = _
Format(pausetime + (start - Timer), "##")
Loop

Sheets(1).Range("BA2").Value = 25

End If

End Sub


Still with no success. Could someone please advise?
This message was edited by Yogi on 2002-10-26 19:23
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
On 2002-10-26 19:16, Yogi wrote:
I was advise not to use a button but initiate the macro by clicking on the cell so I entered the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$BA$2" Then
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("BA2").Value = 25
Do While Timer< start + pausetime
DoEvents ' Yield to other processes.
Sheets(1).Range("BA2").Value = _
Format(pausetime + (start - Timer), "##")
Loop

Sheets(1).Range("BA2").Value = 25

End If

End Sub


Still with no success. Could someone please advise?
This message was edited by Yogi on 2002-10-26 19:23

Hi Yogi
That should be<pre/>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$BA$2" Then

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("BA2").Value = 25
Do While Timer< start + pausetime
DoEvents ' Yield to other processes.
Sheets(1).Range("BA2").Value = _
Format(pausetime + (start - Timer), "##")
Loop

Sheets(1).Range("BA2").Value = 25

End If

End Sub</pre>
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,668
Members
449,463
Latest member
Jojomen56

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