Results 1 to 3 of 3

Displaying a unique countdown timer with Start/Stop/Reset buttons on multiple lines

Threaded View

drememagik Displaying a unique countdown... 01-19-2013, 10:59 AM
abcrobots Re: Displaying a unique... 08-07-2017, 06:16 PM
scottiex Re: Displaying a unique... 08-07-2017, 07:51 PM
  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    FL
    MS-Off Ver
    Excel 2003
    Posts
    1

    Displaying a unique countdown timer with Start/Stop/Reset buttons on multiple lines

    Hello!

    I am hoping that you can help me. I am brand new to VBA (as in, I just learned about it yesterday!) but I am trying to develop a spreadsheet that I can use for a raffle.

    The idea behind it is that there will be approximately 100 prizes, and 100 raffle tickets drawn. When a ticket is drawn, the winner will have 20 minutes to claim their prize or it is forfeited.

    In the Excel spreadsheet, I need to have a row for each prize, along with a countdown timer, and Start, Stop, and Reset buttons. I have gotten the countdown timer and buttons to work for the first row, but how can I repeat this for each additional row, so that I don't have to have 100 copies of the functions that I have written?

    Here are my functions:

    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 = [E4]
    count.Value = count.Value - TimeSerial(0, 0, 1)
    If count <= 0 Then
    count.Font.Color = RGB(255, 0, 0)
    count.Font.Bold = True
    Exit Sub
    End If
    Call Countup
    End Sub
    
    Private Sub Start_Click()
        Call Countup
    End Sub
    
    Private Sub Reset_Click()
    If Cells(5, 4) <> 0 Then
        Application.OnTime Now + TimeValue("00:00:01"), "Realcount", , False
        Range("E4").Value = "0:20:00"
        Range("E4").Font.Color = RGB(0, 0, 0)
        Range("E4").Font.Bold = False
    Else
        Range("E4").Value = "0:20:00"
        Range("E4").Font.Color = RGB(0, 0, 0)
        Range("E4").Font.Bold = False
    End If
    End Sub
    
    Private Sub StopButton_Click()
        Application.OnTime Now + TimeValue("00:00:01"), "Realcount", , False
    
    End Sub

    I am also attaching the current xlsm file, in case that helps. Thank you so much!
    Attached Files Attached Files
    Last edited by JBeaucaire; 01-19-2013 at 08:24 PM. Reason: Added code tags, as per forum rules. Don't forget!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1