Hello!
I have a timer macro that runs when a workbook opens, counts down for 5 minutes. When it reaches zero, it closes without saving (to prevent users from hogging the book - shared workbooks are not appropriate in this case).
All works fine - DoEvents means that users can input data whist the timer runs. However, if they hit the backspace key, the timer stops. It appears that the macor still runs (in the VBA window I still have to hit 'stop' to be able to edit the macro'). Any suggestions?
Script (it's not pretty . . . ):
<VB>
Sub CountdownTimer(seconds As Integer)
Dim Start, Finish, increment, deduction
Cells(1, 30) = seconds
deduction = 5
increment = deduction
Start = timer
Finish = Start + seconds
Do While timer < Finish
Do While timer < Start + increment
DoEvents
Loop
Cells(1, 30) = Cells(1, 30) - deduction
increment = increment + deduction
Loop
Call Close_without_saving
End Sub
In hindsight - it may just be a case of moving DoEvents into first loop</VB>
I have a timer macro that runs when a workbook opens, counts down for 5 minutes. When it reaches zero, it closes without saving (to prevent users from hogging the book - shared workbooks are not appropriate in this case).
All works fine - DoEvents means that users can input data whist the timer runs. However, if they hit the backspace key, the timer stops. It appears that the macor still runs (in the VBA window I still have to hit 'stop' to be able to edit the macro'). Any suggestions?
Script (it's not pretty . . . ):
<VB>
Sub CountdownTimer(seconds As Integer)
Dim Start, Finish, increment, deduction
Cells(1, 30) = seconds
deduction = 5
increment = deduction
Start = timer
Finish = Start + seconds
Do While timer < Finish
Do While timer < Start + increment
DoEvents
Loop
Cells(1, 30) = Cells(1, 30) - deduction
increment = increment + deduction
Loop
Call Close_without_saving
End Sub
In hindsight - it may just be a case of moving DoEvents into first loop</VB>