Automatically Run a Macro at a Certain Time - i.e. Run a Macro at 4:30PM every day

Add to Favorites

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.

Where to install the macro:  ThisWorkbook

Excel Macro to Automatically Run a Macro at a Certain Time

Private Sub Workbook_Open()

'Runs a macro at 4:30 PM
Application.OnTime TimeValue("16:30:00"), "Name_of_Macro"

End Sub

How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.

Tutorial Details
Excel Forum