LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default making a countdown timer

below is the programming that i have created. When i enter "10" in cell A2 I
receive an error. Please assist me.

Public RunWhen As Double
Public timer_value As Integer
Public Const cRunIntervalSeconds = 1 ' 1 Second
Public Const cRunWhat = "The_Sub"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=True
End Sub


Sub The_Sub()

'get the current timer value
'timer_value = Range("timer").Value
timer_value = ActiveCell.FormulaR2C1

'now increase "level now" if the timer has got down to Zero
If timer_value = 0 Then Range("level_now").Value = Range("level_now").Value
+ 1

'now reduce the timer by 1, or reset to the duration if it's on Zero
If timer_value = 0 Then Range("timer").Value = Range("duration").Value Else
Range("timer").Value = timer_value - 1

'now beep in last ten seconds, first getting the new timer value
timer_value = Range("timer").Value
If timer_value 0 And timer_value < 11 Then Beep

StartTimer

End Sub


Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=False
Range("timer").Value = Range("duration").Value
End Sub


Sub PauseTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=False
End Sub


Sub ResumeTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=True
End Sub
--
Rick
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set up countdown timer to countdown days to a specific day Jenny Excel Worksheet Functions 3 May 8th 23 07:43 PM
Need a countdown timer Keith Excel Programming 6 October 3rd 09 03:16 AM
Countdown Timer Mike B.[_2_] Excel Programming 6 June 24th 08 03:01 PM
Countdown timer Jock Excel Programming 15 May 21st 07 02:16 PM
Is a countdown timer possible? aharmer Excel Discussion (Misc queries) 1 February 8th 05 01:47 AM


All times are GMT +1. The time now is 07:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"