+ Reply to Thread
Results 1 to 5 of 5

Can't Stop a Timer

Hybrid View

Exequiel3k Can't Stop a Timer 04-10-2019, 10:21 AM
AliGW Re: Can't Stop a Timer 04-10-2019, 10:26 AM
AliGW Re: Can't Stop a Timer 04-10-2019, 10:31 AM
dominicb Re: Can't Stop a Timer 04-10-2019, 10:45 AM
Exequiel3k Re: Can't Stop a Timer 04-10-2019, 11:30 AM
  1. #1
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Can't Stop a Timer

    Hey all,

    I have a timer set to repeat every 5mins after a certain time, but I just can't get it to stop after 4:35PM

     
    Sub Workbook_Open()
    Application.OnTime TimeValue("09:20:00"), "my_Procedure"
    Application.OnTime TimeValue("09:30:04"), "my_Procedure"
    Application.OnTime TimeValue("09:31:00"), "my_Procedure"
    Application.OnTime TimeValue("09:33:00"), "my_Procedure"
    Application.OnTime TimeValue("09:35:00"), "my_Procedure"
    Application.OnTime TimeValue("09:38:00"), "my_Procedure"
    Application.OnTime TimeValue("09:41:00"), "my_Procedure"
    Application.OnTime TimeValue("09:45:00"), "my_Procedure"
    Application.OnTime TimeValue("09:50:00"), "my_Procedure_repeated"
    MsgBox "Morning Repeater Activated"
    End Sub
    
    
    Sub my_Procedure_repeated()
    Dim nRow As Long
        With ThisWorkbook.Sheets("Tracker")
            nRow = .Range("D" & Rows.Count).End(xlUp).Row + 1
            .Range("B" & nRow).Value = CDate(Format(Now, "hh:mm"))
            .Range("D" & nRow).Value = .Range("D9").Value
            .Range("F" & nRow).Value = .Range("F9").Value
            .Range("H" & nRow).Value = .Range("H9").Value
            .Range("J" & nRow).Value = .Range("J9").Value
            .Range("L" & nRow).Value = .Range("L9").Value
            .Range("N" & nRow).Value = .Range("N9").Value
            .Range("P" & nRow).Value = .Range("P9").Value
            .Range("Q" & nRow).Value = .Range("Q9").Value
        End With
         Call timer 'starting timer again
    End Sub
    
    Private Sub timer()
        Application.OnTime Now + TimeValue("00:05:00"), "my_Procedure_repeated"
    End Sub
    
    Sub stoptimer()
        Application.OnTime Now, Procedure:="timer", Schedule:=False
       'Application.OnTime TimeValue("09:35:00"), "timer", Schedule:=False
    End Sub
    I've tried everything from previous ExcelForums posts, google searches and even previous MS Office Support inquiries but I just can't get it to stop unless I close all excel sheets; which I can't since I have too many important sheets to do so :/

    Any help would be much appreciated!
    Last edited by Exequiel3k; 04-10-2019 at 10:29 AM. Reason: adding [CODE] [/CODE]

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,759

    Re: Can't Stop a Timer

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,759

    Re: Can't Stop a Timer

    Thank you for adding the code tags!

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Can't Stop a Timer

    Good afternoon Exequiel3k

    Your stop routine is missing a parameter : you have to define exactly when your timer started. To do this you will need to set up a variable in your start routine that you can call in the stop routine.

    Chip Pearson has an article here with example code on starting and stopping a timer - use these examples as a guide and your timer should work fine.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  5. #5
    Forum Contributor
    Join Date
    05-17-2016
    Location
    Montreal
    MS-Off Ver
    2013
    Posts
    115

    Re: Can't Stop a Timer

    I see; so I'll have to restructure how I initiate it...
    I'll work on it and see if it works :p

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. start stop timer
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2017, 08:52 AM
  2. [SOLVED] VBA countdown timer help, need it to stop.
    By crowmagnus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2017, 11:27 AM
  3. [SOLVED] How do i stop a timer
    By ANDREAAS in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2016, 01:12 PM
  4. Stop timer
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-23-2016, 05:36 PM
  5. Start/Stop timer
    By JonathanB2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2014, 07:00 AM
  6. [SOLVED] Timer non-stop to run?
    By alee001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2013, 03:46 PM
  7. Replies: 1
    Last Post: 12-12-2012, 08:46 PM

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