Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: How to automatically run a macro at a specific time?

  1. #1


    I want to run a macro at a user specified time. I tried defining a variable as =NOW() and then setting up ado loop statement to say that if the variable equals the user defined time, then run the macro but that jsut seemed to crash my computer.
    Any ideas?


  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Minneapolis, Mn, USA
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)


    I use something like this:

    Public RunWhen As Double
    Public Const cRunWhat = "The_Sub"

    Sub StartTimer()
    RunWhen = Range("c3")
    Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
    End Sub

    Sub The_Sub()
    MsgBox ("Does this Work?")
    End Sub

    Sub StopTimer()
    On Error Resume Next
    Application.OnTime earliesttime:=RunWhen, _
    procedure:=cRunWhat, schedule:=False
    End Sub

    Then I set up range("c3") to equal something like:

    3/4/2002 10:08:00 AM

    Start the process by simply running "Sub StartTimer()".

    But I would set the timedate for sometime in the future, versus now. "Sub The_Sub()" is your procedure to run at the given time.

    Hope this helps. Cheers,


    [ This Message was edited by: NateO on 2002-03-04 08:16 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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