Thread: Countdown timer
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Countdown timer

Yes, You can probably incorporate this into the routine you have set up to
check for inactivity. Here's routine that puts 60 seconds on the clock, and
then displays time remaining in C1 of the active sheet.

Sub DisplayTimeRemaining()
'displays time remaining in seconds
Const TimeAllowed = 60 ' 60 second countdown
Dim TimePassed As Long
Dim StopTime As Long
Dim TimeRemaining As Long

'set up the countdown
TimePassed = Timer
StopTime = TimePassed + TimeAllowed
TimeRemaining = TimeAllowed
'start the countdown
Do While Timer <= StopTime
If Timer TimePassed + 1 Then
TimeRemaining = TimeRemaining - 1
Range("C1") = TimeRemaining
TimePassed = Timer
End If
DoEvents
Loop
Range("C1") = 0
End Sub


"Jock" wrote:

I have used vba code to automatically save then close an pen workbook which
has had no activity for a specified period of time. Is it at all possible to
have a countdown clock displayed is a cell in the workbook indicating to the
user how long is left before shut down?
--
tia

Jock