Backspace stops timer (but not macro?)

MattBee

New Member
Joined
Nov 4, 2009
Messages
1
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>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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