+ Reply to Thread
Results 1 to 20 of 20

Multiple timers

  1. #1
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Multiple timers

    Hi All

    I am trying to create a visual dashboard for cleaning times on some equipment at work, I have one working as i want it and moved onto the second one but when i input the data the timers for both start going super fast!
    The way it should work is the user opens the form and selects the check box against which the item that has been cleaned. this should then set the timer to 10mins and start it. This works ok if only one timer is selected but if both are the timer runs fast, what we should be able to do is select any number of check boxes and or go back to the form and enter another item.

    Timer Code
    Please Login or Register  to view this content.

    Data transfer code
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Multiple timers

    Hi,

    I have not tested the change, but the following should help you solve your problem. You can not call starttimer in your code, because it schedules both timers. Try the following, with changes in red:
    Please Login or Register  to view this content.
    When timing multiple events, multiple timers are not usually needed. One Event Handler can be used to check all times. When there are no active times, there is no longer a need to schedule Application.OnTime.
    If there are a lot of times being monitored, the algorithm can be modified slightly to store the identities of the 'active timing events' in an array.

    I hope this helps.

    Lewis

  3. #3
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Thanks i have just made the amendments and it did the same, i will end up with upto 30 timers which have to count up 72hrs i will do some more googling around timers

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

    Re: Multiple timers

    I do not have any more time today, but I will try to come up with something that will work for you tomorrow or the next day.

  5. #5
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Ok so i have looked at this again and after some advice i have looked at how i can update multiple times at once instead of starting timers. i have the following code which works but wont stop..

    So i press my command button and this puts the date and time now in cell in sheet6 C16 this then adds a preset amount of hours to it and places it in E16 i am then using the following code to count down

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    this adds 1min onto my time in cell C15 which i can then use to calculate the percentage complete, the issue i have is stopping the code i want it to stop when C15 and E15 are the same or > i was thinking of using the following code but want to check first as my i couldnt stop the code when i ran it yesterday. would the following work



    Please Login or Register  to view this content.

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

    Re: Multiple timers

    ... with a slight change.

    Please Login or Register  to view this content.
    ... adds a preset amount of hours to it ...
    Your example code adds 1 minute, not an hour (You may be aware of this, just mentioning).

    To stop a scheduled timer before it fires you need to provide the exact time the timer is scheduled to fire along with the Schedule parameter set to False. For example:

    Please Login or Register  to view this content.
    Last edited by cytop; 07-17-2017 at 03:51 PM.

  7. #7
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Ok so i am learning (or trying)

    So i would put my condition to start start the timer in TimerProc()

    i am lookig at using a form so for example if i use a check box to start the timer i could use:

    Please Login or Register  to view this content.
    that would start the timer for that instance i need to understand how i add multiple statments would it be as simple as

    Please Login or Register  to view this content.

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

    Re: Multiple timers

    I'm back. I have 3 scenarios for you. Each will be in a different post.
    a. Original - The code I posted yesterday seems to work.
    b. Pseudo Timers Scenario A - Each 'pseudo' timer has it's own code.
    b. Pseudo Timers Scenario B - One or more Generic 'pseudo' timers and other custom code as required

    Attached is a modified copy of your workbook that seems to work with the code I posted yesterday - Original Scenario.

    Lewis

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,397

    Re: Multiple timers

    .
    For what it is worth ... this is a two timer project I've used. Here is some of the code. Review remainder in project.
    This is just one way of many to accomplish the goal. Similar to your code.

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

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

    Re: Multiple timers

    This post contains Scenario A code - Each 'pseudo' timer has it's own code. See the attached file which uses 5 timers.

    Please note the following:
    a. A global variable is REQUIRED to save the Scheduled Timer 'Start Time'. stoptimer() is REQUIRED in the ThisWorkbook module when the Workbook closes to prevent the file from being automatically reopened when the
    file is closed, and another workbook is open at the same time in the same instance of Excel. stoptimer() needs the global time value to work properly when the file closes.
    b. There is a small amount of overhead when doing real time processing. The algorithm being used to increment the time by one second with each timer event will cause a 72 hour event to time out at some time after 72 hours. I have not benchmarked the amount of overhead, but 0.01% overhead will cause 72 hours to be 26 seconds late. Larger amounts of overhead will cause an even bigger delay. The solution (for sometime in the future) is to use the actual 'Target' completion date and time.

    In the ThisWorkbook code module:
    Please Login or Register  to view this content.
    In ordinary code module Module1:
    Please Login or Register  to view this content.
    In the UserForm1 Code module - changes in red. NOTE: Calls to D56Timer() and D57Timer() were deleted. Code for the 3 new timers was NOT added to the Userform code.
    Please Login or Register  to view this content.
    Lewis
    Last edited by LJMetzger; 07-17-2017 at 04:29 PM. Reason: UserForm1 changes added

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

    Re: Multiple timers

    This post contains Scenario B code - Generic 'pseudo' timer code. See the attached file.

    ThisWorkbook code omitted - identical to Scenario A.


    In ordinary code module Module1:
    Please Login or Register  to view this content.
    UserForm1 code omitted - identical to Scenario A.

    Lewis

  12. #12
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Thanks Lewis

    I am not sure which one works best for me looking at A and B the workbook code stops the timer when the workbook is closed can i keep it running in the background or is this not possible? I am looking more at Scenario B as my preferred method. as i am looking at 72hrs for the count can i increase the amount the myGblTimerDateAndTime = Now + TimeValue("00:00:01") to say 00:30:00 and then change it for each subsequent D value (D56,D57 etc) to reduce the amount of refreshes

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

    Re: Multiple timers

    Hi Bob,

    a. Yes, the workbook code will stop when the file is closed. If you change the time algorithm to calculate the target completion 'Date and Tme', and save the file (automatically when there is an active timer) when the workbook closes, and start the timer in Workbook_Open() the file will resume processing as if it were never closed each time the file is opened.

    b. The value of myGblTimerDateAndTime can be incremented by any amount you want. One second is great while testing, but it can be 5 minutes or 30 minutes or any combination of minutes and seconds.

  14. #14
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    So on scenario B if i got the file to save whenever there was "Active" in cell I and then would i have to change the set up so it looked at dates and times rather than just times so it had a finish date and time?

    The pic shows the time now in the first cell and the amount of time required to be added in the second cell and the end time in the third cell. using this approach i would get an end date to reference or am i making it too complicated again
    Attached Images Attached Images

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

    Re: Multiple timers

    So on scenario B if i got the file to save whenever there was "Active" in cell I and then would i have to change the set up so it looked at dates and times rather than just times so it had a finish date and time?
    You are exactly correct. I think your picture accurately displays what is needed.

  16. #16
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Ok so i have the following that is now putting the time now in cell P17 and i am trying to put the end date in cell Q17, the end date is calculated from a DTPicker on the form and then i am trying to add 72hrs i can add days or up to 24hrs just cant add more than 24hrs.

    Please Login or Register  to view this content.

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

    Re: Multiple timers

    TimeValue("23:59:59") is the maximum value

    If you are using only hours the following should work:
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Thanks i am getting to grips more with it now and i am playing with the code to make it update every min rather than every second, issue is now i get a Ding sound when it updates can i turn this off?

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

    Re: Multiple timers

    now i get a Ding sound when it updates can i turn this off?
    I don't know. I always have my computer on mute except when I want to access a sound file.

    The following link (which I have NOT tested) may help turn the sound off/on:
    http://wellsr.com/vba/2016/excel/use...p-volume-down/

    I hope this helps.

    Lewis

  20. #20
    Forum Contributor
    Join Date
    05-01-2015
    Location
    Kent, England
    MS-Off Ver
    2013
    Posts
    148

    Re: Multiple timers

    Hi All

    Can anyone help me i am having issues with my multiple timers, i have attached a copy of the sheet. The way its meant to work is the user selects the "Input" button on the main tanks sheet, top right, this opens the form and allows the user to input the data and save it.

    The first issue i am having is when a check box is selected on the form the data should be transferred to the Data sheet by adding a new row for each check box, at the moment its only adding the last check box so it looks like its not adding to my TR value at each step.

    The second issue is that its not setting the start time on sheet Timers to 00:00:00 cells B1 and B4 are working but B7, B10, B13, B16, B19, B22, B25, B28, B31, B34, B37 and B40 are not resetting

    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. Best way to make multiple countdown timers
    By Dave_ross in forum Excel General
    Replies: 19
    Last Post: 02-04-2019, 05:06 PM
  2. Multiple Countdown timers.
    By dawidski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2013, 11:42 PM
  3. Need Multiple Stopwatch Timers on Worksheet
    By texas tornado in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2013, 06:37 PM
  4. Multiple Timers within EXcel
    By Janto724 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-26-2013, 09:07 AM
  5. multiple countdown timers in excel?
    By hollandrob81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2013, 04:12 PM
  6. Setup Multiple Timers
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2010, 04:38 PM
  7. Running multiple timers
    By tropy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-17-2006, 09:44 AM

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