Hi there,
Please try the code below
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Range("c:c"), Target) Is Nothing Then Exit Sub
If Target.Value = "done" Then
Set xRg = Target.Offset(0, -1) 'Find email address
Call Mail_small_Text_Outlook(xRg.Value)
End If
End Sub
Sub Mail_small_Text_Outlook(ByVal xTo As String)
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = xTo
.CC = ""
.BCC = ""
.Subject = "send by cell value test"
.Body = xMailBody
.Display 'or use
' .Send
End With
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
You mentioned that you want to send an email to the PM whose intitials as in the same row that marked as completed. Is his/her email address on the same row? The code in the 6th row helps to find the project managers initials, you can change it to make it find the email address.
Please change the string "done" in the 5th row to the actual string you use to mark the job completed.
Note that you can change the snippet below to your needs.
xMailBody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = xTo
.CC = ""
.BCC = ""
.Subject = "send by cell value test"
.Body = xMailBody
.Display 'or use
' .Send
End With If you have any questions, please don't hesitate to ask me.
Amanda