vba code to only autogenerate 1 email

Kimberly47

New Member
Joined
Sep 28, 2018
Messages
2
[FONT=&quot]I have a code to autogenerate an email if an change is made to cells e11:a33. If I make several changes, I'd only like it to autogenerate the email once. How can I do this? Thanks, [/FONT]


[FONT=&quot]Dim xRg As Range[/FONT]
[FONT=&quot]'Update by Extendoffice 2018/3/7[/FONT]
[FONT=&quot]Private Sub Worksheet_Change(ByVal Target As Range)[/FONT]
[FONT=&quot]'Determine if change was made to cells E11:E33[/FONT]
[FONT=&quot]If Not Intersect(Target, Range("E11:E33")) Is Nothing Then[/FONT]
[FONT=&quot]Call Mail_small_Text_Outlook[/FONT]
[FONT=&quot]End If[/FONT]
[FONT=&quot]End Sub[/FONT]
[FONT=&quot]Sub Mail_small_Text_Outlook()[/FONT]
[FONT=&quot]Dim xOutApp As Object[/FONT]
[FONT=&quot]Dim xOutMail As Object[/FONT]
[FONT=&quot]Dim xMailBody As String[/FONT]
[FONT=&quot]Set xOutApp = CreateObject("Outlook.Application")[/FONT]
[FONT=&quot]Set xOutMail = xOutApp.CreateItem(0)[/FONT]
[FONT=&quot]xMailBody = "LAC team," & vbNewLine & vbNewLine & _[/FONT]
[FONT=&quot]"This LAC Event Management Macro for _ has a status update. Please review. Thanks."[/FONT]
[FONT=&quot]On Error Resume Next[/FONT]
[FONT=&quot]With xOutMail[/FONT]
[FONT=&quot].To = ""[/FONT]
[FONT=&quot].CC = ""[/FONT]
[FONT=&quot].BCC = ""[/FONT]
[FONT=&quot].Subject = "Event Planning Update"[/FONT]
[FONT=&quot].Body = xMailBody[/FONT]
[FONT=&quot].Display 'or use .Send[/FONT]
[FONT=&quot]End With[/FONT]
[FONT=&quot]On Error GoTo 0[/FONT]

[FONT=&quot]Set xOutMail = Nothing[/FONT]
[FONT=&quot]Set xOutApp = Nothing[/FONT]
[FONT=&quot]End Sub[/FONT]
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,215,347
Messages
6,124,421
Members
449,157
Latest member
mytux

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