+ Reply to Thread
Results 1 to 14 of 14

Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

  1. #1
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Question Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    I have a code to sample variable value of cell D1 at every second
    Please Login or Register  to view this content.
    Sampling of cell D1 needs to be done 24x7. While code runs perfectly upto 23:59:59 hrs but after that Timer stops. I have checked it's value reaches to 86397. I tried to reset Timer but VBA gives error that Read Only property can not be changed.
    I tried s = Now + TimeValue("00:00:01") also instead of Timer function but that does not samples value of D1 exactly at 1 second interval. So, I want to use Timer.
    For that I want to know how to reset Timer, if possible?
    Or any other way so that sampling of values of D1 keeps continue after 23:59:59 hrs.

    Thanks.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    If I recall correctly, you were using another macro to call the one in Post #1. that is the one you need to be working with. This one only provides the timing interval, not the start and stop.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Try:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Please Login or Register  to view this content.
    This might work also.

  5. #5
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Thank you very much, porucha vevrku. Now Code works even after 23:59:59 hrs. Thanks for your quick reply.
    Last edited by ansheng; 02-03-2019 at 06:47 AM.

  6. #6
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by JLGWhiz View Post
    Please Login or Register  to view this content.
    This might work also.

    JLGWhiz, This is giving Compile error: Sub or Function not defined. But thanks for your effort & quick reply.

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    What if all cells in the column 'B' are used and there is no room for further entries (12.1 days), of course, if you change "For k = 1 To 100" drastically ?
    Last edited by mjr veverka; 02-03-2019 at 07:47 AM.

  8. #8
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by ansheng View Post
    JLGWhiz, This is giving Compile error: Sub or Function not defined. But thanks for your effort & quick reply.
    OK, apparently you did away with the 'Repeat' macro.
    Regards, JLG

  9. #9
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by porucha vevrku View Post
    What if all cells in the column 'B' are used and there is no room for further entries (12.1 days), of course, if you change "For k = 1 To 100" drastically ?
    Actually this code is small part of a large code. I want to sample D1 values 100 times actually 900 times in column B but after that all these 900 cells clears & process of sampling begins again 900 times starting from B1 to B900. This code is inside infinite loop. I need cells only from B1 to B900.

  10. #10
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by JLGWhiz View Post
    OK, apparently you did away with the 'Repeat' macro.
    Regards, JLG
    Yes, now the actual code has changed significantly from that in Post#1. I have modified the code as per my increased requirements.

  11. #11
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    To avoid complications with 'Timer' use api 'timeGetTime' or 'GetTickCount'.

  12. #12
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by porucha vevrku View Post
    To avoid complications with 'Timer' use api 'timeGetTime' or 'GetTickCount'.
    How to use these api's?

  13. #13
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    ... quite simply and normally ... use forum search ... it will be quite a few ... ... in your case it would look almost the same as with "Timer", e.g.:
    Please Login or Register  to view this content.
    You have about 49 days to overflow your counter.

  14. #14
    Registered User
    Join Date
    07-15-2017
    Location
    India
    MS-Off Ver
    MS Office 2013
    Posts
    11

    Re: Need Help to Reset Timer function in Excel VBA after 23:59:59 hrs

    Quote Originally Posted by porucha vevrku View Post
    Try:
    Please Login or Register  to view this content.

    There is a cell in which time comes from time.is site (web) only 1 time (first of all) by pressing Ctrl+Alt+F5 before starting the macro. Then 00:00:01 gets added every time ' Timer ' runs to that cell and hence clock runs. But I'm unable to get exact 1 second in 's = Timer +1 ' , so I need to adjust value 1 to 0.94 to 0.97 every time I run the macro to get exactly 1 second difference as compared to GPS time. In addition to this after some time clock (time) lags behind or lead ahead 1 second then 2 seconds then 3 seconds & so on than actual GPS time. So I need to adjust 's = Timer +1 ' again & again.
    So why is there a variable second difference? & How can it be made exact as GPS time? Or is there any method to fetch GPS time directly every second in this macro sheet?
    Last edited by ansheng; 02-26-2019 at 11:59 AM.

+ 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. Create running stopwatch/timer with 1 button (start/stop). No reset button.
    By leeroy2612 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2021, 12:59 AM
  2. Replies: 4
    Last Post: 12-17-2018, 07:59 AM
  3. Displaying a unique countdown timer with Start/Stop/Reset buttons on multiple lines
    By drememagik in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2017, 07:51 PM
  4. Need Countdown Timer in Excel with automatic reset to pre-determined value
    By sbowen1310 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2017, 06:19 PM
  5. [SOLVED] formula for count down stop watch with reset timer
    By jb1konobe in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2015, 06:57 PM
  6. Excel Timer function
    By juriemagic in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-23-2014, 01:45 AM
  7. How can I reset a timer?
    By SJB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2009, 12:38 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