email with condition

A

Anift

HI All,
I am working on a worksheet which has a range N11: N33 and has a Numeric
Value,
I want to send a email directly from EXCEL if any cell in this range gets
the value > 2.
If there is more than 1 cell which has value more than 2, two different mail
should go with a Text body, I am writing a code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo EndMacro
If Not Target.HasFormula Then
Set rng = Target.Dependents
If Not Intersect(Range("N11"), rng) Is Nothing Then
If Range("N11").Value > 2 Then Mail_with_Outlook2
'(Macro to send email)
ElseIf Range("N12").Value > 2 Then Mail_with_Outlook1
' (Macro to send email2)
.......
.......

If I use ElseIf, other condition do not get validated if the first condition
is fulfilled

any suggestions??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top