send email based on cell value when value is text

Liam_S

New Member
Joined
Jun 19, 2016
Messages
6
Hi,

I am needing assistance in creating a macro to send an email to a certain person based on a cells value as being a text e.g. "Waiting for Admin". I currently use a drop down menu for cells in column AH. Based off the selection from the drop down I want it to send/display an email using outlook.

I have found how to do this based off a numeric value however I'm a novice to excel macros and can't change it to do it on a text value. I am needing creating the macro and adding into excel.

Any help is greatly appreciated.
 
I'm not sure what you mean. This is what I currently have.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


    Dim myToAdd As String


    If Target.Column = 35 Then


        If Target.Value = "Waiting for Admin" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Admin Complete" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "See Comments" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Need Further Info" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Aaron/Tammy to Complete" Then
            myToAdd = "email@email.com.au"
        ElseIf Target.Value = "Waiting to be contacted" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Waiting for Shift Manager" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Complete" Then
            End
        ElseIf Target.Value = "Ongoing" Then
            End
              ElseIf Target.Value = "" Then
            End
        End If
            
        With CreateObject("Outlook.Application").createitem(0) '0 will create a new email item
            .To = myToAdd
            .Subject = "Gaming Query/Issue Needs Actioning"
            .htmlBody = "[B]Attn: Users[/B]
 The Gaming Query/Issue Log has been updated.
 [B]Reference #(insert number)[/B] needs actioning. Please view the Gaming Query/Issue Log and action as needed.
 [URL="file:///\\M:\File"]Click Here To Open Query/Issue Log[/URL] 
  Once actioned please ensure that that the Query Status is changed appropriately.
 [B][I]Thank you,[/I][/B]

 Auto Email Message from The Gaming Query/Issue Log
"
            .Display 
        End With

    End If


End Sub

I was wanting it if the cell says "complete", and possibly other text values later on, then to display another email message.

As you can tell I am quite the novice :)
 
Last edited:
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I believe you need to add the email body into the If statements:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


    Dim myToAdd As String
 [COLOR=#ff0000]   Dim myEmailBody As String[/COLOR]


    If Target.Column = 35 Then


        If Target.Value = "Waiting for Admin" Then
            myToAdd = "email@email.com.au;"
[COLOR=#ff0000]            myEmailBody = "My Email Body Goes Here"[/COLOR]
        ElseIf Target.Value = "Admin Complete" Then
            myToAdd = "email@email.com.au;"
[COLOR=#ff0000]            myEmailBody = "My Email Body Goes Here"[/COLOR]
        ElseIf Target.Value = "See Comments" Then
            myToAdd = "email@email.com.au;"
[COLOR=#ff0000]            myEmailBody = "etc..........."[/COLOR]
        ElseIf Target.Value = "Need Further Info" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Aaron/Tammy to Complete" Then
            myToAdd = "email@email.com.au"
        ElseIf Target.Value = "Waiting to be contacted" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Waiting for Shift Manager" Then
            myToAdd = "email@email.com.au;"
        ElseIf Target.Value = "Complete" Then
            End
        ElseIf Target.Value = "Ongoing" Then
            End
              ElseIf Target.Value = "" Then
            End
        End If
            
        With CreateObject("Outlook.Application").createitem(0) '0 will create a new email item
            .To = myToAdd
            .Subject = "Gaming Query/Issue Needs Actioning"
[COLOR=#ff0000]            .htmlBody = myEmailBody[/COLOR]


            .Display 
        End With


    End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,670
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top