简体   繁体   中英

How to run an Excel macro every Monday using Windows Task Scheduler

I created a macro that refreshes the data automatically and then it saves the file to a particular folder. I would like to set up a scheduled job that automatically runs my macro every Monday morning.

How can I achieve this?

In the workbook that runs your Macro make sure it is called in the ThisWorkbook Module Workbook_Open

Private Sub Workbook_Open()
    Call YourMacroHere
End Sub

Then go to Task Scheduler and select Create Basic Task

在此处输入图片说明

Then give your task a name

在此处输入图片说明

Click Next and define your schedule

在此处输入图片说明

-> Next ->

在此处输入图片说明

-> Next -> Start a Program

在此处输入图片说明

-> Next -> Browse and select your workbook

在此处输入图片说明

-> Next -> Confirm everything is correct and Finish

在此处输入图片说明

This will then, provided your computer is turned on will then open that Workbook every Monday at 9am. The Workbook_Open() event will then fire executing your macro. You may want to add to your code as well to shutdown the workbook after the macro has finished.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM