daddyfoxuk
Board Regular
- Joined
- Nov 18, 2016
- Messages
- 68
Hi All, i'm wanting to create an auto email to be sent from excel when a cell in I equals more than one, kind of like an alert... However i would like this email to include certain cells of information depending on which cell in I has changed. For example if I10 changes i would like cells A10 to H10 to be copied and sent in the email.
I have the below code but i'm at a loss right now.... Any help or suggestion would be much appreciated! Thank You!!
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("I1:I10000"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 1 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Suspect Part Found" & vbNewLine & vbNewLine & _
"Containment Inspection" & vbNewLine & _
"Please Contact Inspection Area"
On Error Resume Next
With xOutMail
.To = "My Email"
.CC = ""
.BCC = ""
.Subject = "Suspect Part Located"
.Body = xMailBody
.Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
I have the below code but i'm at a loss right now.... Any help or suggestion would be much appreciated! Thank You!!
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("I1:I10000"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 1 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Suspect Part Found" & vbNewLine & vbNewLine & _
"Containment Inspection" & vbNewLine & _
"Please Contact Inspection Area"
On Error Resume Next
With xOutMail
.To = "My Email"
.CC = ""
.BCC = ""
.Subject = "Suspect Part Located"
.Body = xMailBody
.Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub