VBA Timer with rolling list

Status
Not open for further replies.

DutchDisaster

New Member
Joined
Apr 3, 2018
Messages
5
What I was asked to do is to create a countdown timer that starts with the first value in a predetermined list of roundtrip times, and when it reaches zero, it has to move on to the next value and so on, till the list has been completed and then stop. This list with time values will eventually be created daily in another file (on another machine), but will be imported in the timer file each morning.

One thing to remember; this list of times is variable, i.e. it runs from 0800h to 1630h, but due to roundtrips being longer or shorter depending on the required schedule, the amount of roundtrips can change each day.

I have built the timer, which works as required, but I am at a loss how to feed the timer the next value in the list. Right now, the timer uses cell E4 for its starting value, so I'd need the new value to appear there at the end of each cycle.

This is my timer at the moment:

Code:
Public Countdown As Double

Sub StartCountdown()
    Countdown = Now + TimeSerial(0, 0, 1)
    Application.OnTime earliestTime:=Countdown, procedure:="RunCountdown", _
         schedule:=True
End Sub

Sub RunCountdown()
    Sheet2.Range("B2").Value = Sheet2.Range("B2").Value - TimeValue("00:00:01")
    If Sheet2.Range("B2").Value >= TimeValue("12:00:00") Then
        Call StopCountdown
        Range("B2") = Range("F20")
        Exit Sub
    End If
    If Sheet2.Range("B2").Value <= 0 Then
        Range("B2") = Range("E4")
    End If
    StartCountdown
End Sub

Sub StopCountdown()
    On Error Resume Next
    Application.OnTime earliestTime:=Countdown, _
        procedure:="RunCountdown", schedule:=False
End Sub
This is my test setup:

BCDEF
1
200:00:000,0000
3
412:00:0100:15:00
500:14:00
600:13:00
700:12:00
800:11:00
900:10:00
1000:09:00
1100:08:00
1200:07:00
1300:06:00
1400:05:00
1500:04:00
1600:01:00
1700:00:30
1800:00:10
1900:00:01
2000:00:00
2112:00:01

<tbody>
</tbody>
Sheet2
The bottom value in the list is over 12h, as it is the trigger to stop. The generated lists will all have the 12:00:01 value as the last value to stop the countdown sequence. D2 is related to that (used to generate a value in B2 of 00:00:00 after the countdown ends). At the moment, E4 has a simple dropdown list, which is (F4:F21).

So what I need now are suggestions on how to create the rolling list I'm missing.

I'm thinking the required code should be inserted somewhere in the RunCountdown sub?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,493
Office Version
365
Platform
Windows
Duplicate: https://www.mrexcel.com/forum/excel-questions/1057014-vba-timer-rolling-list.html

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread. Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it. Please be patient and do not attempt to post the question again.
 
Last edited:
Status
Not open for further replies.

Forum statistics

Threads
1,082,333
Messages
5,364,675
Members
400,810
Latest member
elbashka

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top