• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Send Emails Based on Changing Cell Values|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Send Emails Based on Changing Cell Values|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosSend Emails Based on Changing Cell …
sp_PrintTopic sp_TopicIcon
Send Emails Based on Changing Cell Values
Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
1
June 11, 2020 - 5:44 am
sp_Permalink sp_Print

Greetings all,

 

i am planning to make an automated sheet that send an email once a f2, f3 , f4 ..... cell reaches certain value.

 

I would like to include the information in cell A2, A3, A4 AND B1, B2, B3... in the email body

 

The plan is to have an email for each row reaching that vlaue ..

 

tried this but its showing me only one email and i coulfnt add the inormation in that row.

 

Dim xRg As Range
'Update by Extendoffice 2018/3/7
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("f2:f10000"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 180 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 = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = "mohd.althobaiti@outlook.com"
.CC = ""
.BCC = ""
.Subject = "6 months"
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub

Can any one help please.

Thank you all.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
June 11, 2020 - 10:19 am
sp_Permalink sp_Print

Hi Mido,

Welcome to the forum.  On the face of it this looks like something I can help with but I'm missing some important information.  

Please always attach your workbook with data when posting a question otherwise I'm guessing as to what data you are working with.

Other info I need:

1. send an email once a f2, f3 , f4 ..... cell reaches certain value. : what values?

2. include the information in cell A2, A3, A4 AND B1, B2, B3 : how so?  In what format?  What's in these cells?  Text?  Numbers? This is where seeing the workbook helps me.

Thanks

Phil

Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
3
June 11, 2020 - 6:35 pm
sp_Permalink sp_Print

Greetings,

 

Thank you for your reply and apologies for missing this information.

 

My objective is send an automated email once the employee reaches 6 months on acting assignment.

 

Technically, once the value in column E reach 180, and automated email should be sent out to the email on column F, stating the corresponding employee name and badge number in column A and B in the email Body.

 

Thank you for you support.

 

I have attached the file without the VBA due to size restriction.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
June 12, 2020 - 12:32 pm
sp_Permalink sp_Print sp_EditHistory

Hi Mido,

The attached file will send emails based on the criteria you stated.

There needs to be some way for the code to be started so it is placed inside a worksheet change event.  Each time the sheet is changed the code will run to check if it needs to send any emails.

You need to record that an email has been sent, so the code knows not to send another email.  The code enters the date an email was sent into a new column, 'Email Sent' for this purpose.

As it is the code will only display the email for you, it won't send it.  This is just for testing purposes so you can check it works as you want.

When you are happy you just need to change the value of the DisplayEmail variable from True to false.  You'll find this in the code towards the top.

Regards

Phil

Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
5
June 12, 2020 - 8:12 pm
sp_Permalink sp_Print sp_EditHistory

Hi Philip,

 

Thank you so much for your support.

Since you are online, is there anyway we can discuss this.

 

Appreciated.

Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
6
June 12, 2020 - 9:03 pm
sp_Permalink sp_Print

This is working just fine dear Philip.

 

Yet, these details change frequently, my plan is to update the data in column 1 , 2 and 3 bi weekly or monthly.

 

With every change the emails will pop again and the record for the email sent column will be changed.

 

Honestly, not sure how can we make this happen with proper control.

 

Truly appreciate your support.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
7
June 12, 2020 - 9:46 pm
sp_Permalink sp_Print

Hi Mido,

The code will send an email when the value in Col E is >= 180.

When an email is sent the code will enter the date the email was sent into Col G.

If there is a date in Col G then another email will not be sent for the same person.

So, whatever changes you make - like adding new people to the table - won't result in multiple emails being sent for the same person.

You can confirm this by running the code once to see the emails that are created (sent) - a date is entered in Col G.

If you run the code again, emails are not created for those people who have already had an email sent.

Regards

Phil

Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
8
June 12, 2020 - 9:56 pm
sp_Permalink sp_Print

Hi dear Philip,

 

Completely understand, however, the process that will take place is basically generating the Acting placement report from SAP, copying name badge and date assigned and paste them all in this automated sheet. What i am trying to say is that this is not gonna be a manual input and adding rows.

 

Thank you and appreciated.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
9
June 12, 2020 - 10:16 pm
sp_Permalink sp_Print

So if you are overwriting the data every time you take a report from SAP, there is no way to know what emails have been sent, with the current code.

You could use Power Query to merge the current table showing emails sent, and the new data from SAP?

Or you could have a workbook that has a sheet where sent emails are recorded.  The SAP report is pasted/imported into a sheet in this workbook and the data from both sheets compared?

Phil

Avatar
Mido TH
Member
Members
Level 0
Forum Posts: 6
Member Since:
June 11, 2020
sp_UserOfflineSmall Offline
10
June 12, 2020 - 10:27 pm
sp_Permalink sp_Print

That would be a solution too. to check and compare duplication once a copy and paste all fields.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
11
June 19, 2020 - 11:40 am
sp_Permalink sp_Print

Hi Mido,

I've created a new sheet and a table on that sheet to keep track of what emails have been sent.

The records will show the person's name, badge number and the date the email was sent.

When you place the new data from SAP into Sheet1, the code checks through all the rows looking for the badge number and checking if that badge number exists n the table on the 2nd sheet.  If the badge number exists n the table, then an email has already bee sent for that person.

Regards

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Scott Miller, Roy Lutke, Jeff Krueger, Darrell Hodge, Francisco Luna
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.