Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't think you can iterate through all pending events or cancel them all in one shabang. I'd suggest setting a module level or global boolean indicating whether or not to fire your event. So you'd end up with something like this:</p> <pre><code>Dim m_AllowSendMailEvent As Boolean Sub SendMail() If Not m_AllowSendMailEvent Then Exit Sub 'fire event here End Sub </code></pre> <h2>Edit:</h2> <p>Add this to the TOP of the sheet module which contains the range which contains the date/time value you're after:</p> <pre><code>' Most recently scheduled OnTime event. (Module level variable.) Dim PendingEventDate As Date ' Indicates whether an event has been set. (Module level variable.) Dim EventSet As Boolean Private Sub Worksheet_Change(ByVal Target As Range) Dim SendTimeRange As Range ' Change to your range. Set SendTimeRange = Me.Range("B9") ' If the range that was changed is the same as that which holds ' your date/time field, schedule an OnTime event. If Target = SendTimeRange Then ' If an event has previously been set AND that time has not yet been ' reached, cancel it. (OnTime will fail if the EarliestTime parameter has ' already elapsed.) If EventSet And Now &gt; PendingEventDate Then ' Cancel the event. Application.OnTime PendingEventDate, "SendEmail", , False End If ' Store the new scheduled OnTime event. PendingEventDate = SendTimeRange.Value ' Set the new event. Application.OnTime PendingEventDate, "SendEmail" ' Indicate that an event has been set. EventSet = True End If End Sub </code></pre> <p>And this to a standard module:</p> <pre><code>Sub SendEmail() 'add your proc here End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload