what do you want the trigger for the email to be? someone changing the value of C1 or D1?
Assuming that you want to test for the email requirement when either C1 or D1 is changed then:
First you need to establish the current values prior to any changes - do this first off by using a worksheet activate event on the sheet you're working on
Private Sub Worksheet_Activate()
Cells(65536, 3) = Cells(1, 3)
Cells(65536, 4) = Cells(1, 4)
End Sub
You then need to set up a selection change event that tests the values in C1 and D1 to those original values of C1 & D1 which are stored in row 65536. If they are the same then you don't need to go any further. If they have changed you then need to test them.
The below code does not use the Outlook object model (though you could use this if you so desired), this makes mailing workbooks across different operating versions far easier though it requires a little more delving around to find the correct syntax as opposed to using OL's built in olmailitem.
Personally I don't like selection_change events as they will run everytime you move cell which is not particularly efficient. But if this is how you want to do it then this should work for you.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(65536, 3) <> Cells(1, 3) Or Cells(65536, 4) <> Cells(1, 4) Then
If Cells(1, 3) < Cells(1, 4) Then
Set aOutlook = GetObject(, "Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
'set Importance
aEmail.Importance = 2
'Set Subject
aEmail.Subject = "C1 less than C2 Alert..."
'Set Body for mail
aEmail.Body = Cells(1, 2) & vbLf & vbLf & Cells(4, 8)
'Set attachment if required
'aEmail.ATTACHMENTS.Add ActiveWorkbook.FullName
'Set Recipient
aEmail.Recipients.Add Cells(1, 1)
'Send Mail
aEmail.Send
Cells(65536, 3) = Cells(1, 3)
Cells(65536, 4) = Cells(1, 4)
End If
End If
End Sub
Display More