Use the Application.OnTime method to schedule code that will run in one minute.
Your code will look something like this (Untested):
Sub CreateNewSchedule() Application.OnTime EarliestTime:=DateAdd("n", 1, Now), Procedure:="macro_name", Schedule:=True End Sub Sub macro_name() If Value > 10 Then SendEmail Else CreateNewSchedule End If End Sub
You might want to save the time of the next schedule in a global variable so that the Workbook_BeforeClose event can cancel the next schedule. Otherwise, Excel will open the workbook again.
Public nextScheduledTime As Date Sub CreateNewSchedule() nextScheduledTime = DateAdd("n", 1, Now) Application.OnTime EarliestTime:=nextScheduledTime , Procedure:="macro_name", Schedule:=True End Sub Sub macro_name() If Value > 10 Then SendEmail Else CreateNewSchedule End If End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Application.OnTime EarliestTime:=nextScheduledTime, Procedure:="macro_name", Schedule:=False End Sub
Then you can continue to use Excel between scheduled.
source share