Hi all. Hope you can help. I have never been trained on VBA and am trying to create a countdown timer. I have acheived that however the timer is needed on 15 different tabs, which represent 15 different trials and therefore needs to be specific to that tab.
At the moment if I am on any particular test the timer works fine, however if I move off that tab the timer stops on the original tab and starts on the current tab. I need to be able to move about tabs with the active test timer still running and the non active test timers static. The timer is a countdown with the start time dictated by a "sample time" column as the sample time may be changed during the trial. So I have used if statements to look up the column from the bottom to determine the sample time for that particular phase of the trial. The code I currently have in Module 1 is
Sub Countup()
Dim CountDown As Date
CountDown = Now + TimeValue("00:00:01")
Application.OnTime CountDown, "Realcount"
End Sub
Sub Realcount()
Dim count As Range
Set count = [t13]
count.Value = count.Value - TimeSerial(0, 0, 1)
If count <= 0 Then
Beep
MsgBox "WEIGH THE TRAY"
Exit Sub
End If
Call Countup
End Sub
I also have a timer override in the timer, so that if we have to stop part way through a specific time period I can overwrite to allow for remaining time, and then I can reset that to look back at the sample time column for the next phase of the trial
Is there any way to have this code specific to a particular sheet, e.g. Test 1, Test 2 etc
I tried to insert an image to show what the timer buttons look like in the sheet, but am not sure how to do that on here.
I also realise that I could just download a timer app, but you know how it is, you get into something like this and are close to the end result and cannot let it beat you
Thanks
David
At the moment if I am on any particular test the timer works fine, however if I move off that tab the timer stops on the original tab and starts on the current tab. I need to be able to move about tabs with the active test timer still running and the non active test timers static. The timer is a countdown with the start time dictated by a "sample time" column as the sample time may be changed during the trial. So I have used if statements to look up the column from the bottom to determine the sample time for that particular phase of the trial. The code I currently have in Module 1 is
Sub Countup()
Dim CountDown As Date
CountDown = Now + TimeValue("00:00:01")
Application.OnTime CountDown, "Realcount"
End Sub
Sub Realcount()
Dim count As Range
Set count = [t13]
count.Value = count.Value - TimeSerial(0, 0, 1)
If count <= 0 Then
Beep
MsgBox "WEIGH THE TRAY"
Exit Sub
End If
Call Countup
End Sub
I also have a timer override in the timer, so that if we have to stop part way through a specific time period I can overwrite to allow for remaining time, and then I can reset that to look back at the sample time column for the next phase of the trial
Is there any way to have this code specific to a particular sheet, e.g. Test 1, Test 2 etc
I tried to insert an image to show what the timer buttons look like in the sheet, but am not sure how to do that on here.
I also realise that I could just download a timer app, but you know how it is, you get into something like this and are close to the end result and cannot let it beat you
Thanks
David