+ Reply to Thread
Results 1 to 7 of 7

Stop timer

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Stop timer

    I am trying to switch between two routines with a timer. The start works fine however the stoptimer throws a 1004 error. Can anyone point out the obvious (not obvious to me and that's why I am pulling my hair out). Many thanks!
    Please Login or Register  to view this content.
    Last edited by aprildu; 02-22-2016 at 09:19 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Stop timer

    Have a look at http://www.cpearson.com/excel/OnTime.aspx

    It should have all the information you need & doing it yourself is the best way to learn

    Cheers

  3. #3
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Stop timer

    Thanks philb1. I did google but somehow the above codes just won't work. I was hoping someone could point out what the problem is.

  4. #4
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Stop timer

    I haven't done this in a while so had to work it out as well. I added a bit to show the rows if they were hidden when you pressed the stop button.
    Sorry I changed it around a bit to how my brain works (Back to front normally)
    Try the code below

    Sorry I can't post the workbook as the site won't let me. I put start & stop buttons on sheet 1, the Start button macro is StartTimer, Stop button is StopTimer

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: Stop timer

    Thank you! It worked. The difference is the conditions? I guess the errors must be caused by those? Error 1004 usually is caused by name, range... oh well.
    Last edited by aprildu; 02-23-2016 at 01:58 PM.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Stop timer

    Good job Philb1.

    The difference is the 'On Error resume Next' which is needed to suppress the Runtime error that occurs when the timer is not scheduled (either not scheduled or when RotateRows() is executing).

    It is also good programming practice to put StopTImer() in the Workbook_BeforeClose() routine in the ThisWorkbook code module. If this is not done, the spreadsheet may unexpectedly 'rise from the dead'.

    Lewis
    Last edited by LJMetzger; 02-23-2016 at 03:28 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    08-22-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2019
    Posts
    716

    Re: Stop timer

    Glad it worked out.

    Thanks for the compliment Lewis & thank you both for the rep

    Cheers
    Phil

+ 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. Timer Stop when other CommandButton Clicked
    By iqballud in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2015, 09:23 AM
  2. Start/Stop timer
    By JonathanB2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2014, 07:00 AM
  3. how to stop a macro timer running more then once
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-06-2013, 08:58 PM
  4. [SOLVED] Timer non-stop to run?
    By alee001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2013, 03:46 PM
  5. stop watch and timer in excel
    By Suraj3825 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2013, 05:50 AM
  6. Replies: 1
    Last Post: 12-12-2012, 08:46 PM
  7. stop this countdown timer macro
    By jacksten in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-25-2012, 10:57 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