+ Reply to Thread
Results 1 to 2 of 2

Ontime - Run At given date and time

  1. #1
    Valued Forum Contributor saravnepali's Avatar
    Join Date
    01-14-2019
    Location
    Sydney Australia
    MS-Off Ver
    2010
    Posts
    447

    Ontime - Run At given date and time

    I have to submit report at different times.

    So, I have one program to submit report

    Now, I have a list of date & time I want to submit the report.

    How do I make excel look at the list of time and run the programme as appropriate.

    Sub report_submit ()
    'look at the range values on sheet1 Range A1:A5 of this workbook

    2/11/2020 07:30
    3/11/2020 07:30
    6/11/2020 07:30
    9/11/2020 07:30
    12/11/2020 07:30


    'If current time is as per the list run / call the sub - Submit_Report

    end sub

    The challange is syntax for ONtime needs earliest time, how do we feed it the time that we want the report to run

    And if we make excel to run it now (say on how say
    2/11/2020 07:30) to prepare excel to keep looking for next possible timing given that the frequency of the report to be submitted is not constant

    Any help will be appreciated.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,747

    Re: Ontime - Run At given date and time

    You make a call to OnTime for each of your times. Then you must leave Excel open the entire time for the sub to be called on the appropriate day/time. The reason that the documentation says "earliest time" is that a software application that depends on the operating system to provide the time and interrupts cannot guarantee that it will be exactly at that time, but it will be so close you won't be able to tell the difference. (Real-time embedded applications run on bare metal so they have absolute control over timing. Windows on a PC, not so much.)

    If current time is as per the list run / call the sub - Submit_Report
    If you try to program this yourself instead of relying on OnTime you have the challenge of constantly checking to see if it's time to run, and then making a note that it has already run so it doesn't do it twice for the same time.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Application.ontime to stop at a certain time
    By rey745 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-14-2019, 10:36 AM
  2. Application.ontime, Running time increasing.
    By olle3770 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2014, 07:24 AM
  3. application.ontime date and time problem
    By ckjason in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 03:23 AM
  4. Execute Ontime method in simultaneous time
    By irwan. in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-25-2012, 02:14 AM
  5. Replies: 5
    Last Post: 07-20-2012, 12:42 PM
  6. Can Application.OnTime be stopped at a specified time
    By rhudgins in forum Excel General
    Replies: 4
    Last Post: 04-14-2011, 05:38 PM
  7. OnTime Events with Reliable Time Source
    By inwalkedbud in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-14-2008, 01:21 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