![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
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? Regards |
|
|
|
#2 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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, _ schedule:=True 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, Nate [ This Message was edited by: NateO on 2002-03-04 08:16 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|