VBA -Emailing cell information from a change to cell

Sct013

New Member
Joined
Nov 17, 2005
Messages
1
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
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,222,143
Messages
6,164,174
Members
451,880
Latest member
2da

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