Selected Answer
Hi Narutoszym and welcome to the Forum
Yes, the timer will countup by adding the seconds (TimeValue), as per your code.
I think you can have 5 timers running simultaneously (at least on my old PC!) but the VBA code needs to have separate condes and varaible names to avoid ambiguity.
In the attached file, there are countup timers in cells A1, A5, A9, A13 and 17 and buttons to start, stop and reset each timer. You can start them independently from where they have reached (as the file leaves me) or reset and restart.
The duplicated code (including the reset macro is shown below with changes in bold for timer 2 only but you'll get the idea:
Public interval As Date, interval2 As Date, interval3 As Date, interval4 As Date, interval5 As Date
Sub timer()
interval = Now + TimeValue("00:00:01")
Range("A1") = Range("A1") + TimeValue("00:00:01")
Application.OnTime interval, "timer"
End Sub
Sub stop_timer()
On Error Resume Next
Application.OnTime EarliestTime:=interval, Procedure:="timer", Schedule:=False
End Sub
Sub reset_timer()
Range("A1") = 0
End Sub
Sub timer2()
interval2 = Now + TimeValue("00:00:01")
Range("A5") = Range("A5") + TimeValue("00:00:01")
Application.OnTime interval2, "timer2"
End Sub
Sub stop_timer2()
On Error Resume Next
Application.OnTime EarliestTime:=interval2, Procedure:="timer2", Schedule:=False
End Sub
Sub reset_timer2()
Range("A5") = 0
End Sub
Sub timer3()
interval3 = Now + TimeValue("00:00:01")
Range("A9") = Range("A9") + TimeValue("00:00:01")
Application.OnTime interval3, "timer3"
End Sub
Sub stop_timer3()
On Error Resume Next
Application.OnTime EarliestTime:=interval3, Procedure:="timer3", Schedule:=False
End Sub
Sub reset_timer3()
Range("A9") = 0
End Sub
Sub timer4()
interval4 = Now + TimeValue("00:00:01")
Range("A13") = Range("A13") + TimeValue("00:00:01")
Application.OnTime interval4, "timer4"
End Sub
Sub stop_timer4()
On Error Resume Next
Application.OnTime EarliestTime:=interval4, Procedure:="timer4", Schedule:=False
End Sub
Sub reset_timer4()
Range("A13") = 0
End Sub
Sub timer5()
interval5 = Now + TimeValue("00:00:01")
Range("A17") = Range("A17") + TimeValue("00:00:01")
Application.OnTime interval5, "timer5"
End Sub
Sub stop_timer5()
On Error Resume Next
Application.OnTime EarliestTime:=interval5, Procedure:="timer5", Schedule:=False
End Sub
Sub reset_timer5()
Range("A17") = 0
End Sub
Note that I added the line
On Error Resume Next in the stop macros (to avoid problems if the stop macro is run without the timer running.
Hope this helps