Closed Thread
Results 1 to 5 of 5

timer code not working

  1. #1
    Registered User
    Join Date
    07-07-2013
    Location
    Northampton uk
    MS-Off Ver
    Excel 2010
    Posts
    146

    timer code not working

    here is my timer code:

    Sub startTimer()
    Application.OnTime Now + TimeValue("00:00:01"), "increment_count"
    End Sub

    Sub increment_count()
    Range("G12").Value = Range("G12") - 1
    startTimer
    PauseTime = 0
    Start = Timer
    Do While Timer < Start + PauseTime
    Loop
    End Sub

    Sub StopTimer()
    Application.OnTime Now + TimeValue("00:00:01"), "increment_count", schedule:=False
    End Sub

    my problem is that the timer does not stop at "0" it continues -1 -2 etc. Also where would i put the following code:

    MsgBox "Time Up! How Did You Do?"
    Me.Hide
    Exit Sub

    and when the ok button is clicked i need it to open up userform1

    can someone please help

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: timer code not working

    Hi, flyinghigher2011,

    please wrap your procedure up in code-tags (and maybe explain in words what you are after).

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    07-07-2013
    Location
    Northampton uk
    MS-Off Ver
    Excel 2010
    Posts
    146

    Re: timer code not working

    sorry about the code thing!!

    ok here is the code

    Please Login or Register  to view this content.
    everything works ok until the end and the counter is "0" then my pop up message comes up then the code for my stop button turns yellow, the code is from my module 7, one other thing is that the counter the continues counting -1 -2 -3 -4 etc which it should not do, it should reset back to 65 seconds

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: timer code not working

    Hi, flyinghigher2011

    what about the code I posted in your other thread at http://www.excelforum.com/excel-prog...own-timer.html - I think that should do the trick.

    Ciao,
    Holger

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

    Re: timer code not working

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    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]

Closed 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