I am new to using vb code in excel and am having trouble trying to email the contents of cell ranges. What I am trying to accomplish is when someone changes the qty of a cell below a certain # an email will send the contents or information from other cells of the same row. (example when cell D8 (is changed) and falls below 6 an email will send the information from cells D2 thru D5.Below is the code I am using.
Thanks for any help you can give me.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$H$2" Then
If Target.Value < 6 Then
If MsgBox("Confirm EMail notification", vbQuestion Or vbYesNo) = vbYes Then
EmailNotify "Out of stock cutters ", Target.Value
End If
End If
End If
End Sub
Public Sub EmailNotify(SubjectText As String, BodyText As String)
Dim appOL As Object
Dim objMail As Object
Const EMAIL_ADDRESS = "email@.com"
Set appOL = CreateObject("Outlook.Application")
Set objMail = appOL.CreateItem(0) ' olmailitem=0
With objMail
.Recipients.Add EMAIL_ADDRESS
.Subject = reorder
.Body = BodyText
.Send
End With
Set objMail = Nothing
Set appOL = Nothing
End Sub
Thanks for any help you can give me.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$H$2" Then
If Target.Value < 6 Then
If MsgBox("Confirm EMail notification", vbQuestion Or vbYesNo) = vbYes Then
EmailNotify "Out of stock cutters ", Target.Value
End If
End If
End If
End Sub
Public Sub EmailNotify(SubjectText As String, BodyText As String)
Dim appOL As Object
Dim objMail As Object
Const EMAIL_ADDRESS = "email@.com"
Set appOL = CreateObject("Outlook.Application")
Set objMail = appOL.CreateItem(0) ' olmailitem=0
With objMail
.Recipients.Add EMAIL_ADDRESS
.Subject = reorder
.Body = BodyText
.Send
End With
Set objMail = Nothing
Set appOL = Nothing
End Sub