Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sd sd is offline
external usenet poster
 
Posts: 9
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default 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.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default 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.





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 180
Default 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



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
time and auto macro run by setting time ddiicc Excel Programming 1 September 29th 05 05:32 AM
Help with Macro to Convert Date/Time to Time Only Bill[_26_] Excel Programming 5 August 25th 04 01:50 PM
excel - macro - automatic initiation of a macro at a pre-specified "system time" arunjoshi[_3_] Excel Programming 3 May 1st 04 09:42 AM


All times are GMT +1. The time now is 11:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"