ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run a macro at a cretin time of day (https://www.excelbanter.com/excel-programming/346929-run-macro-cretin-time-day.html)

sd

Run a macro at a cretin time of day
 
Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.


K Dales[_2_]

Run a macro at a cretin time of day
 
Yes, with the OnTime method. The following would run the sub called MySub at
2:45 pm:
Application.OnTime TimeValue("14:45:00"), "MySub"

--
- K Dales


"sd" wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.



Kaak[_50_]

Run a macro at a cretin time of day
 

Application.OnTime (.....


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=489389


Nigel

Run a macro at a cretin time of day
 
Use the application.ontime command. eg....

Application.OnTime TimeValue("14:58:00"), "your_macro_name"

--
Cheers
Nigel



"sd" wrote in message
oups.com...
Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.




Martijn[_2_]

Run a macro at a cretin time of day
 
Open your excel, open with Alt-F11 the visual basic editor, Open Help
look for method: OnTime.

Put the code + My_Procedure in the personal macro book.

some examples :
My_procedure will start after 15 seconds from now
Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"

or at 17.00
Application.OnTime TimeValue("17:00:00"), "my_Procedure"

or to cancel it:
Application.OnTime EarliestTime:=TimeValue("17:00:00"), _
Procedu="my_Procedure", Schedule:=False

I think this can do the trick.

Good luck with it. Let me know if it's working.
grtx's Martijn


"sd" schreef in bericht
oups.com...
Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.




bpeltzer

Run a macro at a cretin time of day
 
I've taken a different approach... Create the macro as an Auto_Open() macro,
or invoke it on the Workbook_Open event. Then set up the Excel file
containing the macro as a Windows Scheduled Task.

"sd" wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.



Martijn[_2_]

Run a macro at a cretin time of day
 
Good approach but your macro starts only when you open the workbook not on a
certain time.

You are right when you say "if excel is not open than the other macro's
don't work also"

grtx's Martijn


"bpeltzer" schreef in bericht
...
I've taken a different approach... Create the macro as an Auto_Open()

macro,
or invoke it on the Workbook_Open event. Then set up the Excel file
containing the macro as a Windows Scheduled Task.

"sd" wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.





bpeltzer

Run a macro at a cretin time of day
 
The task scheduler allows me to indicate when the workbook should be opened
and, therefore, when the macro runs. So Excel doesn't need to be running;
it's kicked off at the designated time by the scheduler.


"Martijn" wrote:

Good approach but your macro starts only when you open the workbook not on a
certain time.

You are right when you say "if excel is not open than the other macro's
don't work also"

grtx's Martijn


"bpeltzer" schreef in bericht
...
I've taken a different approach... Create the macro as an Auto_Open()

macro,
or invoke it on the Workbook_Open event. Then set up the Excel file
containing the macro as a Windows Scheduled Task.

"sd" wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.






Gordon Rainsford[_2_]

Run a macro at a cretin time of day
 
Won't you have a problem if the workbook is already open?

Gordon Rainsford


bpeltzer wrote:

The task scheduler allows me to indicate when the workbook should be opened
and, therefore, when the macro runs. So Excel doesn't need to be running;
it's kicked off at the designated time by the scheduler.


"Martijn" wrote:

Good approach but your macro starts only when you open the workbook not on a
certain time.

You are right when you say "if excel is not open than the other macro's
don't work also"

grtx's Martijn


"bpeltzer" schreef in bericht
...
I've taken a different approach... Create the macro as an Auto_Open()

macro,
or invoke it on the Workbook_Open event. Then set up the Excel file
containing the macro as a Windows Scheduled Task.

"sd" wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.







--
Gordon Rainsford
London

bpeltzer

Run a macro at a cretin time of day
 
Sure; there are trade-offs everywhere. My approach fails if the workbook is
open; the other fails if it isn't. But since I typically schedule these
things to run overnight, having the files open isn't usually an issue.
Besides, the macro files are special-purpose and wouldn't normally be open
except when I want them to run. And I love coming arriving at work with lots
of my reports already completed ;-)

"Gordon Rainsford" wrote:

Won't you have a problem if the workbook is already open?

Gordon Rainsford
London


Dave Peterson

Run a macro at a cretin time of day
 
If you haven't looked at Chip Pearson's notes about OnTime, you may want to
review them:
http://www.cpearson.com/excel/ontime.htm

sd wrote:

Can a macro be set up to run at a specific time? I have a macro I want
to run if it is 2:58pm can this be done? I think excel needs to be open
in order to do this but I am not sure if a macro can run with out an
actual event.


--

Dave Peterson


All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com