Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Ontime Method (Excel )

    Hi all I need help,
    I want to run a procedure at a certain time of the day, I would like to load a userform automatically.

    I read the help files, but didn't help that much, here's what I have so far

    Application.ontime("11:20:00"), Test, 30, schedule = False

    Question, where do I put this information in e.g....worksheet, workbook, module? any ideas?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Ontime Method (Excel )

    You must create a macro, i.e. a procedure in a module, and run that macro:

    Sub DoSomething()
    Application.OnTime TimeValue("11:20"), "Test"
    End Sub

    Note that the time is specified by using TimeValue("11:20"), I could also have used TimeSerial(11, 20, 0), and that the name of the procedure to be run is passed as a string.

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Ontime Method (Excel )

    Thank you Hans,

    What triggers it to run the sub? Is it the Application?

    It didn't work, I created a sub, and it didn't run at the time I wanted.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Ontime Method (Excel )

    You must start the macro DoSomething (or whatever you called it). Excel then starts a timer (think of it as an egg timer) that goes off at the specified time.

    Note: Excel must remain open for this. If you quit Excel, the timer won't run any more.

  5. #5
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Ontime Method (Excel )

    I just wanted to make this post to end this,

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Ontime Method (Excel )

    Does it do what you want now?

  7. #7
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Ontime Method (Excel )

    Yes Thanks Hans,

    I just wanted to post that file so that someone else could use the example if they wanted.

    What I have learned is that Microsoft Help file are not too good for Newbies like myself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •