Run a macro on a date!
doctor_vai
-
tompols Posted messages 1273 Registration date Status Contributor Last intervention -
tompols Posted messages 1273 Registration date Status Contributor Last intervention -
Good evening!
As part of a small project, I would like a macro to run automatically in Excel every Monday at the beginning of each week!
How can I do this?
Thanks in advance
As part of a small project, I would like a macro to run automatically in Excel every Monday at the beginning of each week!
How can I do this?
Thanks in advance
Configuration: Windows XP Firefox 3.5.2
7 answers
-
-
try something like this
If weekday(Now,2)=2 then
Your macro...
end if
and insert this code into the code page of your Excel workbook and change the dropdown list in the top left from "general" to "workbook"
this will launch the macro when opening the workbook
only condition: you must open the workbook every Monday morning... -
-
Now is a VBA function that contains the current date and time corresponding to your system's (computer) date and time.
To learn more, select the word now on your code page and press F1... the VBA help page will open directly to the help for the Now function... -
Hello,
the solution using a macro with functions like NOW requires that the workbook be open and that a loop be in place to wait, which seems a bit tricky...
Personally, I would lean more towards a scheduled task in Windows that opens the workbook while placing the macro in the Workbook_Open() event... be careful with 2 points: test the day in the macro to see if this workbook can be opened at other times, and the PC must be turned on for the scheduled task to run.... -
-
Well, to launch a process automatically at a certain time, you really need to be able to periodically check that time to know when to execute the procedure. This can only be done by a process that runs continuously with a loop like "while not now = moment, wait x seconds....." => a process runs continuously to check the "moment" and calls the procedure when necessary, hence my suggestion to use the Windows "scheduler" service....