+ Reply to Thread
Results 1 to 4 of 4

Userform Timer to run on loop

  1. #1
    Registered User
    Join Date
    04-25-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    3

    Userform Timer to run on loop

    Hello,

    I have a timer in a userform which counts up and displays the count in a text box. However what I would like to do is to have the timer loop and begin again from zero once it reaches a preset limit, say for ease 10 seconds. So the timer would count to 10 then start again at zero and continuously repeat.

    The code I have so far is:

    Please Login or Register  to view this content.
    I've tried editing the btnStart sub however I cant seem to to get it to repeat. Can anyone help?

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Userform Timer to run on loop

    You need to declare boolStopPressed scoped to the module or whatever this code is in.
    You should also use
    Please Login or Register  to view this content.
    at the top of the module to require all variables be declared before use (If you do, this will cause compiler errors when you try to run the code, until all are declared).

    The problem is boolStopPressed is never explicitly declared so when you use it in btnStart_Click it is created but only local to that procedure. The same in btnStop_Click, that copy of the variable is local to the procedure btnStop_Click so they can never 'interact'.

    Please Login or Register  to view this content.
    I've no idea what dteStopped or dteElapsed are supposed to do, but the same applies. If they are referenced in separate procedures then they must be in scope for those procedures, not local to them.

  3. #3
    Registered User
    Join Date
    04-25-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    3

    Re: Userform Timer to run on loop

    Apologies I have not pasted the option explicit part of my code. I don't have access to the document at the minute but shall include it when I can.

    However this doesn't help me with making the timer loop. Using the code above along with the option explicit the timer itself works great I just can't get it to loop.

  4. #4
    Registered User
    Join Date
    04-25-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    3

    Re: Userform Timer to run on loop

    I have pasted all the code from my userform below and included the file at the bottom. If anyone has any ideas how I can make the timer loop I would be much appreciated.

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Stop timer, Do While Loop from executing.
    By Wijnand1 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-28-2017, 03:24 AM
  2. [SOLVED] Loop through a userform listbox & copy certain columns into txtboxes on userform loop next
    By mtilbury in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2016, 10:10 AM
  3. [SOLVED] Timer on userform - run in background if we close the userform
    By nicenari in forum Excel General
    Replies: 6
    Last Post: 06-10-2015, 02:54 PM
  4. Timer on Userform
    By TubbzUK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2014, 09:10 PM
  5. Countdown Timer Loop
    By Angusbuttler in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2014, 06:26 PM
  6. Userform Timer
    By BPB in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-05-2012, 11:02 AM
  7. Timer Loop
    By Slyone2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2010, 01:24 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