Selected Answer
Natalia
You're right, the tutorial countdown timer stops when you change to another worksheet.
The reason is that the macros in the module refer to Range("A1") and VBA assumes that that cell (in this case A1) is on the active sheet so when you swap sheets it tries to read A1 on the new sheet for example and the macro fails.
The solution is pretty easy- define the worksheet that the timer exists on. In the revised code below, those additions are in bold:
Public interval As Date
Sub timer()
' TeachExcel.com
' Check if the timer is finished and exit the macro if it is
If Sheet1.Range("A1").Value = 0 Then Exit Sub
' Remove 1 second from the timer
Sheet1.Range("A1").Value = Sheet1.Range("A1").Value - TimeValue("00:00:01")
' Set when the macro should run again - should be the same time value
' as the previous line.
interval = Now + TimeValue("00:00:01")
' Make this macro run again in 1 second
Application.OnTime interval, "timer"
End Sub
Sub stop_timer()
' TeachExcel.com
' Stop the timer macro from running
Application.OnTime EarliestTime:=interval, Procedure:="timer", Schedule:=False
End Sub
Sub reset_timer()
' TeachExcel.com
' Default time for the timer
Sheet1.Range("A1").Value = "00:05:00"
End Sub
(Note there are various ways to define the worksheet, as you will learn).
Now, when you swap sheets, the timer will keep going (see attached file, and swap to other sheets).
Hope this helps.