Hi Mohan,

 

Thanks for your update. I couldn't find  where to insert your code.

Could you please insert your code 'If Target.Column <> Range("N1").Column
Then Exit Sub' in my below code. so as I could run thru' quickly.

Code:-

 Sub sendEmail()

    Dim objOL As Object

    Dim objMail As Object

    Dim sEmail As String

    Dim sEmailColumn As String

    Dim sSubject As String

    Dim sBody As String

    Dim lDataRow As Long

    Dim cl As Range

    'Set column with email address

    sEmailColumn = "Z"

     For Each cl In Selection.Resize(, 1)

        

        lDataRow = cl.Row

        

        If cl.Parent.Range("N" & lDataRow).Value = "Failure" Then

            With cl.Parent

                sEmail = .Range(sEmailColumn & lDataRow)

                sSubject = Range("B" & lDataRow)

                sBody = "URL/Test Condition: " & .Range("G" & lDataRow) &
vbNewLine & "Step A" 

            End With

            

            On Error GoTo Cleanup

            

            Set objOL = CreateObject("Outlook.Application")

    

            Set objMail = objOL.CreateItem(0)

            With objMail

                .To = sEmail

                .Subject = sSubject

                .Body = sBody

                .Display

            End With

        End If

    Next cl

 

 

From: [email protected] [mailto:[email protected]]
On Behalf Of ?> lal?? ?sa??
Sent: 31 August 2012 21:55
To: [email protected]
Subject: Re: $$Excel-Macros$$ Need update on the attached Macro

 

Just use this line of code before calling sendmail procedure

If Target.Column <> Range("N1").Column Then Exit Sub

Hope it helps you

Regards,
Lalit Mohan



On Fri, Aug 31, 2012 at 5:50 PM, Selva <[email protected]> wrote:

Hi All,

 

Need an update on the attached macro file. Based on this file, whenever the
Column N  drop down is selected for 'Failure', an outlook mail generates and
ready to be sent. If 'Success' is selected no mails will be sent. But my
issue is whenever I select for 'Failure' in Column O. Two mails are being
generated for Column N and for Column O. But I want to restrict it to one
mail for that cell which I have selected only. Can any one help me on this?

 

Code:-

 

Sub sendEmail()

 

    Dim objOL As Object

    Dim objMail As Object

    Dim sEmail As String

    Dim sEmailColumn As String

    Dim sSubject As String

    Dim sBody As String

    Dim lDataRow As Long

    Dim cl As Range

    'Set column with email address

    sEmailColumn = "Z"

     For Each cl In Selection.Resize(, 1)

        

        lDataRow = cl.Row

        

        If cl.Parent.Range("N" & lDataRow).Value = "Failure" Then

            With cl.Parent

                sEmail = .Range(sEmailColumn & lDataRow)

                sSubject = Range("B" & lDataRow)

                sBody = "URL/Test Condition: " & .Range("G" & lDataRow) &
vbNewLine & "Step A" 

            End With

            

            On Error GoTo Cleanup

            

            Set objOL = CreateObject("Outlook.Application")

    

            Set objMail = objOL.CreateItem(0)

            With objMail

                .To = sEmail

                .Subject = sSubject

                .Body = sBody

                .Display

            End With

        End If

    Next cl

    For Each cl In Selection.Resize(, 1)

        

        lDataRow = cl.Row

        

        If cl.Parent.Range("O" & lDataRow).Value = "Failure" Then

            With cl.Parent

                sEmail = .Range(sEmailColumn & lDataRow)

                sSubject = Range("B" & lDataRow)

                sBody = "URL/Test Condition: " & .Range("G" & lDataRow) &
vbNewLine & "STEP B" & vbNewLine & "<Insert Screenshots here>"

            End With

            

            On Error GoTo Cleanup

            

            Set objOL = CreateObject("Outlook.Application")

    

            Set objMail = objOL.CreateItem(0)

            With objMail

                .To = sEmail

                .Subject = sSubject

                .Body = sBody

                .Display

            End With

        End If

    Next cl

    For Each cl In Selection.Resize(, 1)

        

        lDataRow = cl.Row

        

        If cl.Parent.Range("P" & lDataRow).Value = "Failure" Then

            With cl.Parent

                sEmail = .Range(sEmailColumn & lDataRow)

                sSubject = Range("B" & lDataRow)

                sBody = "URL/Test Condition: " & .Range("G" & lDataRow) &
vbNewLine & "STEP C" & vbNewLine & "<Insert Screenshots here>"

            End With

            

            On Error GoTo Cleanup

            

            Set objOL = CreateObject("Outlook.Application")

    

            Set objMail = objOL.CreateItem(0)

            With objMail

                .To = sEmail

                .Subject = sSubject

                .Body = sBody

                .Display

            End With

        End If

    Next cl

    For Each cl In Selection.Resize(, 1)

        

        lDataRow = cl.Row

        

        If cl.Parent.Range("Q" & lDataRow).Value = "Failure" Then

            With cl.Parent

                sEmail = .Range(sEmailColumn & lDataRow)

                sSubject = Range("B" & lDataRow)

                sBody = "URL/Test Condition: " & .Range("G" & lDataRow) &
vbNewLine & "STEP D" & vbNewLine & "<Insert Screenshots here>"

            End With

            

            On Error GoTo Cleanup

            

            Set objOL = CreateObject("Outlook.Application")

    

            Set objMail = objOL.CreateItem(0)

            With objMail

                .To = sEmail

                .Subject = sSubject

                .Body = sBody

                .Display

            End With

        End If

    Next cl

 

Regards,

Selva Jayapal

Accenture - IDC, Chennai

PMO - Operations

Desk - +91 44 426 70619

Mobile - +91 7708658033

Office Communicator :  <mailto:[email protected]>
[email protected]

-- 
Join official facebook page of this forum @
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups
"MS EXCEL AND VBA MACROS" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected]
<mailto:excel-macros%[email protected]> .
 
 

 

-- 
Join official facebook page of this forum @
https://www.facebook.com/discussexcel
 
FORUM RULES (1120+ members already BANNED for violation)
 
1) Use concise, accurate thread titles. Poor thread titles, like Please
Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will
not get quick attention or may not be answered.
 
2) Don't post a question in the thread of another member.
 
3) Don't post questions regarding breaking or bypassing any security
measure.
 
4) Acknowledge the responses you receive, good or bad.
 
5) Cross-promotion of, or links to, forums competitive to this forum in
signatures are prohibited. 
 
6) Jobs posting is not allowed.
 
7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.
 
NOTE : Don't ever post personal or confidential data in a workbook. Forum
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups
"MS EXCEL AND VBA MACROS" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
 
 

-- 
Join official facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES (1120+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

6) Jobs posting is not allowed.

7) Sharing copyrighted ebooks/pirated ebooks/their links is not allowed.

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].


Reply via email to