+ Reply to Thread
Results 1 to 9 of 9

stop this countdown timer macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Angry stop this countdown timer macro

    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 = [E1]
    count.Value = count.Value - TimeSerial(0, 0, 1)
    If count <= 0 Then
    MsgBox "SORRY - TIME UP!"
    Exit Sub
    End If
    Call Countup
    End Sub
    Last edited by arlu1201; 05-16-2012 at 03:43 AM. Reason: Please put code tags in future.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: stop this countdown timer macro

    Dim CountDown As Date
    
    Sub CountUp()
        CountDown = Now + TimeValue("00:00:01")
        Application.OnTime CountDown, "RealCount"
    End Sub
    
    Sub RealCount()
    Dim count As Range
        Set count = [E1]
        count.Value = count.Value - TimeSerial(0, 0, 1)
        If count <= 0 Then
            MsgBox "SORRY - TIME UP!"
            Exit Sub
        End If
        Call CountUp
    End Sub
    
    Sub StopCount()
        Application.OnTime CountDown, "RealCount",, False
    End Sub

  3. #3
    Registered User
    Join Date
    05-16-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: stop this countdown timer macro

    Hi Bob,
    This StopCount creates an error 1004 but it does stop the macro "RealCount". When I end this error "RealCount" continues.
    Sub StopCount()
       Application.OnTime CountDown, "RealCount", , False
    End Sub
    I have a "Correct" macro button and a "Wrong" macro button. I run the StopCount as the first action for both of them.

    I really appreciate your help with this. It is a Jeopardy Quiz for Senior Citizens where they have a fixed time to answer "RealCount"

    If they answer (right or wrong) within the time allowed it stops the countdown. If they don't - they run out of time.

    Thanks heaps for taking the time to look at it - if I can get this bit right - the game is ready to go.

    Sincerely,

    Jack Stenhouse
    Last edited by arlu1201; 05-17-2012 at 04:15 AM. Reason: Code tags

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: stop this countdown timer macro

    Jack,

    I am a bit unclear on what happens. What is the process, what do these people enter, and who clicks the Correct/Wrong buttons? What macros do these buttons fire?

  5. #5
    Registered User
    Join Date
    05-16-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: stop this countdown timer macro

    Hi Bob,
    The idea is that the question is displayed, the countdown starts.Jeopardy Scoring.JPG
    I do all of the button pressing. The correct and wrong buttons update the scores of the players.
    They both do a fair amount of work . . . an example is . . .
    Sub CORRA()
    '
    ' CORRA Macro
    '
    
    '
        Application.Goto Reference:="RIGHT"
        ActiveCell.FormulaR1C1 = "Y"
        Application.Goto Reference:="RIGHT"
        Selection.ClearContents
        Application.Goto Reference:="OK"
        Selection.ClearContents
        Application.Goto Reference:="WHO"
        ActiveCell.FormulaR1C1 = "A"
        Application.Goto Reference:="TEMPA"
        ActiveCell.FormulaR1C1 = "Y"
        Application.Goto Reference:="MULTIPLIER"
        ActiveCell.FormulaR1C1 = "1"
        Application.Goto Reference:="FINALA"
        Selection.Copy
        Application.Goto Reference:="PREVA"
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.Goto Reference:="MULTIPLIER"
        Selection.ClearContents
        Application.Goto Reference:="TEMPA"
        Selection.ClearContents
        Sheets("QUESTION").Select
        Application.Goto Reference:="controla"
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Bold"
            .Size = 12
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        Application.Goto Reference:="controlb"
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Bold"
            .Size = 12
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight2
            .TintAndShade = 0.599993896
            .ThemeFont = xlThemeFontNone
        End With
        Application.Goto Reference:="controlc"
        With Selection.Font
            .Name = "Arial"
            .FontStyle = "Bold"
            .Size = 12
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ThemeColor = xlThemeColorLight2
            .TintAndShade = 0.599993896
            .ThemeFont = xlThemeFontNone
        End With
        Application.Goto Reference:="R1C1"
    End Sub
    Surprisingly . . . they all work except that the clock keeps counting down even when the question is answered.

    I appreciate the time you have spent on this. Maybe I should have your StopCount call these macros instead of the other way around?

    I have attached an image of the scoring screen - three players - three rights - three wrongs.

    The A, B, C buttons identify the person and start the clock.

    Again, thanks for your effort.

    Sincerely

    Jack Stenhouse
    Last edited by arlu1201; 05-18-2012 at 03:24 AM.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: stop this countdown timer macro

    ...and don't forget the code tags that you correctly used in your earlier post.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  7. #7
    Registered User
    Join Date
    05-16-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: stop this countdown timer macro

    Hi again Bob,
    I am still trying to get this RealCount macro to stop if I press the "correct" or "wrong" macro buttons.
    Your "StopCount" macro creates a 1004 error but does seem to stop RealCount.
    I know this is only for a game but it would be nice to solve it.
    I have attached the Jeopardy file to give you a better idea of what I am trying to achieve.
    (I hope this is OK to do?). There is nothing harmful in this file.
    The intended use for the game is Senior Citizens and some disabled kids I work with on a voluntary basis.
    I appreciate any help you can give me.
    Sincerely

    Jack Stenhouse

    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 = [E1]
        count.Value = count.Value - TimeSerial(0, 0, 1)
        If count <= 0 Then
            MsgBox "SORRY - TIME UP!"
            Exit Sub
        End If
        Call CountUp
    End Sub
    
    Sub StopCount()
        Application.OnTime CountDown, "RealCount", , False
    End Sub
    Attached Files Attached Files

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: stop this countdown timer macro

    I have put it for you this time. At the beginning of your code, you should type [code] and at the end [/code]
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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