Listing Procedures That Use the onKey Method to Set and Reset a Key Combination

Sub SetKey()


End Sub

Sub DeleteAll()

Selection.Clear End Sub

Sub ResetKey()

End Sub

Running a Procedure at a Specific Time

If you need to run a procedure at a specific time, use the OnTime method: Application.OnTime(EarliestTime, Procedure[, LatestTime][, Schedule])

EarliestTime The time (and date, if necessary) you want the procedure to run. Enter a date/time serial number.

Procedure The name (entered as text) of the procedure to run when the

EarliestTime arrives.

LatestTime If Excel isn't ready to run the procedure at EarliestTime (in other words, if it's not in Ready, Cut, Copy, or Find mode), it will keep trying until LatestTime arrives. If you omit LatestTime, VBA waits until Excel is ready. Enter a date/time serial number.

Schedule A logical value that determines whether the procedure runs at

EarliestTime or not. If Schedule is True or omitted, the procedure runs. Use False to cancel a previous OnTime setting.

The easiest way to enter the time serial numbers for EarliestTime and LatestTime is to use the TimeValue function:

TimeValue(Time) Time

A string representing the time you want to use (such as "5:00PM" or "17:00").

For example, the following formula runs a procedure called Backup at 5:00 p.m.:

Application.OnTime _

EarliestTime:=TimeValue("5:00PM"), _ Procedure:="Backup"

0 0

Post a comment