ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a macro on a specific time (https://www.excelbanter.com/excel-programming/367099-running-macro-specific-time.html)

Viktor Ygdorff

Running a macro on a specific time
 
I would like to run a macro at a specific time every day automatically e.g. I
would like to run my macro at 12:00 GMT every day without having to do
anything (except writing the code of course). Is this possible and does Excel
and the spreadsheet has to be open in order for the macro to run? Please help
me! Thank you very much!

Tom Ogilvy

Running a macro on a specific time
 
Excel and the spreadsheet have to be open when the macro runs.

You can use the windows schedular to open excel/the workbook

In the workbook_Open event, put in code to trigger the code you want to run
and close Excel.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

I would like to run a macro at a specific time every day automatically e.g. I
would like to run my macro at 12:00 GMT every day without having to do
anything (except writing the code of course). Is this possible and does Excel
and the spreadsheet has to be open in order for the macro to run? Please help
me! Thank you very much!


Nigel RS[_2_]

Running a macro on a specific time
 
Yes you can, Excel needs to remain open.

Use the following (you could put in the open workbook event)

Application.OnTime TimeValue("12:00:00"), "myCode"

At 12 noon the code myCode procedure runs at the end of the procedure the
event is retriggered to run again at 12:00:00

Sub myCode()
' this code runs at 12:00:00

' code here as required

' reset trigger for new start time
Application.OnTime TimeValue("12:00:00"), "mycode"
End Sub


Cheers
Nigel RS

"Viktor Ygdorff" wrote:

I would like to run a macro at a specific time every day automatically e.g. I
would like to run my macro at 12:00 GMT every day without having to do
anything (except writing the code of course). Is this possible and does Excel
and the spreadsheet has to be open in order for the macro to run? Please help
me! Thank you very much!



All times are GMT +1. The time now is 05:44 PM.

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