Another method.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim FoundEmail As Range
If Target.Cells.Count > 1 Then Exit Sub
If Target = "x" Then
If Not Application.Intersect(Range("G2:G10"), Target) Is Nothing Then
If Target.Offset(0, -2) <= 10 Then
Set FoundEmail = Sheets("Email").Range("A:A").Find(What:=Cells(Target.Row, 3), _
LookAt:=xlWhole, _
MatchCase:=False)
If FoundEmail Is Nothing Then
MsgBox "Cannot match name on Email address sheet. ", vbExclamation, "No Match Found"
Else
Call Testing(FoundEmail.Offset(, 1).Value2)
End If
End If
End If
End If
End Sub
Sub Testing(Email As String)
Dim Subj As String
Dim Msg As String, URL As String
Subj = Cells(ActiveCell.Row, 1)
Msg = ""
Msg = Msg & "Dear " & Cells(ActiveCell.Row, 3) & "," & vbCrLf & vbCrLf & Cells(ActiveCell.Row, 2) & vbCrLf & vbCrLf & " Thank You. "
'Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")
'Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")
'Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
'Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
'Wait two seconds before sending keystrokes
'Application.Wait (Now + TimeValue("0:00:02"))
'Application.SendKeys "%s"
End Sub
Bookmarks