Schedules a procedure to be run at a specified time in the future (either at a specific time of day or after a specific amount of time has passed).
Use Now + TimeValue(time) to schedule something to be run when a specific amount of time (counting from now) has elapsed. Use TimeValue(time) to schedule something to be run a specific time. The value of EarliestTime is rounded to the closest second. Set Schedule to False to clear a procedure previously set with the same Procedure and EarliestTime values. Procedure must take no arguments and cannot be declared in a custom class or form.
Dim dtEarliestTime As Date: dtEarliestTime = Dim strProcedure As String: strProcedure = Application.OnTime EarliestTime:=dtEarliestTime, Procedure:=strProcedure
The following arguments are required:
The following arguments are optional
LatestTime - The latest time at which the procedure can be run. For example, if LatestTime is set to EarliestTime + 30 and Microsoft Excel is not in Ready, Copy, Cut, or Find mode at EarliestTime because another procedure is running, Excel will wait 30 seconds for the first procedure to complete. If Excel is not in Ready mode within 30 seconds, the procedure won't be run. If this argument is omitted, Excel will wait until the procedure can be run