View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Norman Jones
 
Posts: n/a
Default E-mail notifications from Excel based on dates in speadsheets

Hi DWBAUS,

I need the Email notification to be triggered by the cell date as related
to the present or computer date.
e.g I have a maintenance sheet which I want to notify the respective
managers of an upcoming maintenance due say a week prior.
I think I can use the computer date versus the cell date minus a week
but am struggling.


To trigger your email macro, try something like:

'=============
Private Sub Workbook_Open()
Dim SH As Worksheet
Dim Rng As Range
Dim blSent As Boolean

Set SH = Me.Sheets("Maintenance") '<<==== CHANGE
Set Rng = SH.Range("A1") '<<==== CHANGE

With Rng
blSent = .Offset(0, 1).Value = "SENT"

If Not blSent Then
If IsDate(.Value) Then
If .Value <= Date Then
Call YourMacroName '<<==== CHANGE
.Offset.Offset(0, 1).Value = "SENT"
End If
End If
End If
End With

End Sub
'<<=============

Change the sheet name to the sheet of interest; change A1 to the cell which
contains the date value. YourMacroName is the name of the Ron de Bruin email
macro which you have copied into a standard code module.

The above procedure is workbook event code and should be pasted into the
workbook's ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

---
Regards,
Norman