Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

(80% Discount Ends Soon!)

Run a Macro Every X Seconds, Minutes, or Hours

This Excel macro allows you to run any macro at a set time interval.  You can set this to run itself or another macro every so many seconds, minutes, or hours.  However, in order for this to work, you will have to run the macro at least once after the workbook in which it is contained is opened.  Basically, this macro runs a sort of time loop and, in order to start the loop, you must run the macro at least once.

As it is now, the macro will run itself every interval.  So, all you need to do is to put your macro code underneath where it says "Put your code here" and you should be good to go.  If you want this to run another macro, just replace "RunMacro" (that comes at the end of the macro) with the name of the macro that you want to run.

By default, this macro runs every 5 minutes.  If you want to change that, simply change this part of the code "00:05:00" to whatever you want with hours on the left, minutes in the middle, and seconds on the right.


Where to install the macro: Module


Run a Macro Every X Seconds, Minutes, or Hours

Select All
Sub RunMacro()
   
    'Put your code here
   
    Application.OnTime Now + TimeValue("00:05:00"), "RunMacro"
   
End Sub