Automatically run an Excel macro at a certain time. This allows you to not have to worry about running a macro every day. This macro will, on its own, run another macro in your workbook at a certain time in the day. This is a great macro to use to automate your Excel spreadsheets.
This macro only works in the ThisWorkbook vba section and not a module. Also, it will only work after you save the workbook with this macro and then reopen the macro. This is because of the fact that the workbook being opened triggers this macro to run. As it is now, this macro will run at 4:30 PM. The time is always local with this macro. That is because the time determined by the macro is taken from your computer. This is important because if the time on your computer, bottom right hand corner in windows, is incorrect, the macro will still run when it, your computer, says it is the time that is also put into the macro. Sounds a little confusing at first but just make sure that the time displayed by your operating system is correct.
To run this macro, just make sure that you replace Name_of_Macro with the name of the macro inside of your Excel workbook that you want to run. Also, replace 16:30:00 with the time that you want your macro to run. The time in Excel macros is listed in what is sometimes called military time but what is standard for Europe and much of the rest of the world, so just take note of this fact. The first set of zeros is for the hours; the second set is for the minutes; and the third set is for the seconds.
Private Sub Workbook_Open()
'Runs a macro at 4:30 PM
Application.OnTime TimeValue("16:30:00"), "Name_of_Macro"
End Sub