??????

G

George

Ladies and Gentlemen:

In 2003, Ron De Bruin wrote a VBA code LET EXCEL AUTOMATICALLY E-MAIL
A SPECIFIC E-MAIL ADDRESS EACH TIME A PARTICULAR CELL EQUALS "Y" OR
"True". His did it through a change event in cell "A1" as an example.
However, my situation is a little bit different from his. Here is my
situation: I need to enters number in two different columns, say
column A and column B. The PERCENTAGE different betwenn column A and
column B IN THE SAME ROW (say Cn=(Bn-An)/An where n is the index of
the row number) will be calculated automatically in the column C. What
I am trying to figure out is whenever Cn is greater than 20%, I would
like a message sent to my outlook mailbox. Any ideas?

Thanks,




The following is the code that Ron De Bruin wrote for your reference:

The change event will run the code when you change the cell
It must be placed in a sheet module


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
If Target.Value = "Y" Or Target.Value = "True" Then
Mail_with_outlook
End If
End If
End Sub


This sub in a normal module


Change Display to Send if you like it
Don't forget to set a reference to Outlook


How do you that:
1: Go to the VBA editor, Alt -F11
2: Tools>References in the Menu bar
3: Place a Checkmark before Microsoft Office Outlook ? Object Library
? is the Excel version number


Sub Mail_with_outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strto As String
Dim strcc As String
Dim strbcc As String
Dim strsub As String
Dim strbody As String


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)


strto = "(e-mail address removed)"
'Or this with the address in a cell
'strto = Sheets("Sheet1").Range("a1").Value
strcc = ""
strbcc = ""
strsub = "Cell A1 is changed"
strbody = "something you want"


With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
.Display
End With
End Sub
 
C

Corey

Below?
Ladies and Gentlemen:

In 2003, Ron De Bruin wrote a VBA code LET EXCEL AUTOMATICALLY E-MAIL
A SPECIFIC E-MAIL ADDRESS EACH TIME A PARTICULAR CELL EQUALS "Y" OR
"True". His did it through a change event in cell "A1" as an example.
However, my situation is a little bit different from his. Here is my
situation: I need to enters number in two different columns, say
column A and column B. The PERCENTAGE different betwenn column A and
column B IN THE SAME ROW (say Cn=(Bn-An)/An where n is the index of
the row number) will be calculated automatically in the column C. What
I am trying to figure out is whenever Cn is greater than 20%, I would
like a message sent to my outlook mailbox. Any ideas?

Thanks,




The following is the code that Ron De Bruin wrote for your reference:

The change event will run the code when you change the cell
It must be placed in a sheet module


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("C:C"), Target) Is Nothing Then
If Target.Value >= "20" Then
Mail_with_outlook
End If
End If
End Sub


This sub in a normal module


Change Display to Send if you like it
Don't forget to set a reference to Outlook


How do you that:
1: Go to the VBA editor, Alt -F11
2: Tools>References in the Menu bar
3: Place a Checkmark before Microsoft Office Outlook ? Object Library
? is the Excel version number


Sub Mail_with_outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strto As String
Dim strcc As String
Dim strbcc As String
Dim strsub As String
Dim strbody As String


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)


strto = "(e-mail address removed)"
'Or this with the address in a cell
'strto = Sheets("Sheet1").Range("a1").Value
strcc = ""
strbcc = ""
strsub = "Cell A1 is changed"
strbody = "something you want"


With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
.Display
End With
End Sub
 
G

George

Corey:

Thank you so much for the help!

I put the following into a sheet module because it is a
worksheet_Change event;

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("C:C"), Target) Is Nothing Then
If Target.Value >= "20" Then
Mail_with_outlook
End If
End If
End Sub




I also put the following part into a regular module AFTER I check the
option of "Microsoft Office Outlook ? Object Library".

Sub Mail_with_outlook()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim strto As String
Dim strcc As String
Dim strbcc As String
Dim strsub As String
Dim strbody As String


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)


strto = "(e-mail address removed)" 'I changed this to my
e-mail address
'Or this with the address in a cell
'strto = Sheets("Sheet1").Range("a1").Value
strcc = ""
strbcc = ""
strsub = "Cell A1 is changed"
strbody = "something you want"


With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = strbody
.Display
End With
End Sub

After I did the above, nothing happens. Please advise!

Thanks again,

George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Email on value change (Formula) 6
Send Email 4
Send Email VBA 3
Mail Multiple Sheets via PDF Q 5
E-mail if Cell B33 = Yes 2
Converting an Excel file to PDF Q 1
EMAIL 1
active row copy into Outlook 0

Top