+ Reply to Thread
Results 1 to 15 of 15

Timer VBA issues

  1. #1
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Timer VBA issues

    All,

    A faint cry for help, I have sort of bolted together a timer, the issue that I have is that the top timer has 3 sections with a message window to step on, the bottom timer runs independently, the problem is when the message button is activated it stops all timers on the spreadsheet I need the bottom timers to continue .

    I attach the file to try and make it clearer.

    Timer X401 Process 2.xlsm

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Timer VBA issues

    This is the "beauty" of MsgBox. It stops the operation of macros until it is closed.
    The simplest solution is to build a UserForm that is similar to MsgBox. Instead of MsgBox, you will run Userform in non-modal mode (Userform1.Show vbModeless).

    Artik

  3. #3
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9
    Quote Originally Posted by Artik View Post
    This is the "beauty" of MsgBox. It stops the operation of macros until it is closed.
    The simplest solution is to build a UserForm that is similar to MsgBox. Instead of MsgBox, you will run Userform in non-modal mode (Userform1.Show vbModeless).

    Artik
    mmm how do I do that

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Timer VBA issues

    Added UserForm1 and code in Module2. Also changed the contents of the procedures in Module1.

    Artik
    Attached Files Attached Files

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Timer VBA issues

    See if the approach adopted in my sport timer is of any assistance, it does not use a dedicated timer (it takes it time differences from the system clock) therefore not interupted/delayed by message boxes.
    I have inserted a message box to demo - record one end time then wait 20/30 seconds and dismiss the message box and record another end time the difference should be that time the message box is present plus your reaction time.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  6. #6
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    Artik, you are very nearly a genius and thankyou so much for your help but I need to the top timer to not start until the OK button has been clicked

    The top 3 timers work as a third of the total time i.e. timer one activates, then click Ok timer 2 activates then click Ok then timer 3 activates each with OK buttons to confirm

    not all heroes wear capes

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Timer VBA issues

    I left your philosophy of working, but shortened slightly the code. Times can be set only when Timers are NOT running. Otherwise the sheet is locked.
    You have a serious homework assignment. You need to analyze and understand this code.
    Good luck.

    Artik
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    Thanks so much mate, I will check this out and try and work out what and how you did it

    Much respect, Thanks

  9. #9
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    Arif

    Its great and so nearly there, once the timers start I still need the reset button to work in case CIP is completed before the maximum window < time of the tanks (Bottom timers)

    Also the top timer, the total time should be the max time and the first two need to be adjustable via cell X D and E 2, example if the total max time is 42 hours and CIP 1 is done after 10 hours and CIP 2 is done after 20 hours the CIP 3 needs to be 12 hours to not break the max threshold.

    Although the timers are showing the max threshold the CIP's can be completed before

    BTW I really really appreciate your help I am reading through the code and learning a lot

  10. #10
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    Oh dear I think I made it considerably worse, also the more I restart the timers the faster the timers get, I'm learning loads but getting in a right mess and the tank 5 has stopped working
    Attached Files Attached Files
    Last edited by Delbateman1974; 01-31-2023 at 06:58 AM.

  11. #11
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    OK I think the only issue is now that the counter speeds up each time its is used and the third counter on the top timer continues after restart please help....
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    OK Artik final one, most of this is working now apart from the fact if you click the buttons multiple times the counts get faster, I have looked and looked and cannot work this out at all

    I have added a zero button and this helps, but its not fool proof at all

    Please please help me
    Attached Files Attached Files

  13. #13
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Timer VBA issues

    I have briefly looked at your app - if I have understood the structure correctly you are intercepting one 'ticker' with multiple cases - is this correct.
    If so I had a similar problem developing the attached file a year or two back - as each event was activated the time interval would speed up.
    My solution was as the attached file - put each case on its own dedicated 'ticker'.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Timer VBA issues

    Quote Originally Posted by Delbateman1974 View Post
    I am reading through the code and learning a lot
    I can see by the publication times of the posts that you have sat on the project a bit. But let me say brutally: "not enough".
    Taming multiple ticking bombs is not easy at all.
    Some facts:
    1. wanting to stop an initiated OnTime event (before the time expires), you need to know the exact time when it should execute. To know this time, you need to store it somewhere for future reference. This is the solution used by torachan. Note that module-level (or global) variables "remember" the stored values between running macros, so if you want to reset them to the initial state, you need to do it explicitly. It won't do it by itself.
    2. If the button that runs the macro that initiates OnTime does not have proper protection, then every click on the button initiates another event. And then multiple timers are running at the same time, which "accelerate" the ticking. Each event subtracts 1 second, so if there are 3 timers running for one cell, 3 seconds are subtracted with each second.
    3 Runtime error and abruptly aborting the execution of the macro (pressing the [End] button in the window that appears), among other things, resets all variables and unloads the running forms from memory, but does NOT reset the initiated OnTime events. If the events refer to public variables, further action can cause a big mess because the variables have been reset.

    I rarely use OnTime events to build timers. For seconds (and fractions of seconds) countdown, I use the stable class presented by Karl E. Peterson.

    Delbateman1974, I can see that you are a bit at a loss. But I also see that you were not lying on the couch waiting for the task to resolve itself. Attached is the revised code with your new functionality.

    Artik
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    01-26-2023
    Location
    Bridgwater
    MS-Off Ver
    365
    Posts
    9

    Re: Timer VBA issues

    Artik, You are a king among men. Thanks you so much this is perfect now I need to understand it

    Again Thankyou D

+ 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. Replies: 7
    Last Post: 07-08-2019, 01:23 PM
  2. Countdown timer Working BUT starting the timer repeatedly SPEEDS UP TIMER!
    By Vinospam in forum Excel Programming / VBA / Macros
    Replies: 67
    Last Post: 03-30-2019, 06:42 PM
  3. [SOLVED] Timer issues
    By mrpwebb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2015, 02:02 PM
  4. VBA MACRO issues for start/stop timer on job sheet.
    By voidcreativ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2015, 05:54 AM
  5. Vba macro issues for job timer sheet.
    By voidcreativ in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-14-2015, 05:14 PM
  6. Having multiple issues with countdown timer
    By Telperion in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2014, 05:15 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