Excel to Outlook on condition

W

William

Sending an email message from Excel 2003 using Outlook 2003 is rather easy. But how do I program to send such an e-mail when a certain condition is fulfilled in Excel
e.g. A1=5, B1=6; C1=A1+B1. A message should only be sent when C1>10.
 
B

Bob Phillips

You could use the Worksheet_Calculate event to trap when C1 goes over 10.

Dim fSent as Boolean

Private Sub Worksheet_Calculate()
If Not fSent Then
If Me.Range("C1").Value > 10 Then
sendMyMail
fSent = True
EndIf
Else
If Me.Range("C1").VAlue <= 10 Then
fSent = False
End If
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

William said:
Sending an email message from Excel 2003 using Outlook 2003 is rather
easy. But how do I program to send such an e-mail when a certain condition
is fulfilled in Excel.
 
R

Ron de Bruin

Hi William

You can use the change event in the Sheet module

Right click on a sheet tab and choose view code
Paste the code there
Alt-Q to go back to Excel


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("C1"), Target) Is Nothing Then
If Target.Value > 10 Then
YourMacroName
End If
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


William said:
Sending an email message from Excel 2003 using Outlook 2003 is rather easy. But how do I program to send such an e-mail when a
certain condition is fulfilled in Excel.
 
Top