+ Reply to Thread
Results 1 to 24 of 24

Macro needed to send auto email with contents of cell on corresponding row as trigger cell

  1. #1
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Macro needed to send auto email with contents of cell on corresponding row as trigger cell

    I have a spreadsheet that tracks production status.
    At the end of a project the project manager updates the project to 95% because it wont be 100% complete until it goes through our Quality department.


    I have completed the macro to send an email when any part of the production is at 95% (Completion percents are in column D)

    Now, the part I am having trouble on is, once the email is generated.. I would like the subject line to be the title of the document that is ready to be checked by our Quality Department.

    The title of the documents is in column B.

    So to recap, Column B has a Document Titles, column D has the Percent Complete.
    My current macro sends an email to the QC Department when a certain document is at 95% (column D), but in that email I would like the title of the Document which is the same row, but in column B to generate in the subject line or in the body of the email even.

    PLEASE HELP!

    Thanks a Bunch!!
    Last edited by ExcelShi; 06-15-2015 at 11:11 AM. Reason: Title

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: I need a macro code to

    Probably help everyone, including you, if you share the code you have.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: I need a macro code to

    TMS, Thanks! & Apologies!
    The code I am currently using is:

    Sub Make_Outlook_Mail_With_File_Link()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String


    If ActiveWorkbook.Path <> "" Then
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strbody = "<font size=""3"" face=""Calibri"">" & _
    "Quality Assurance Department:<br><br>" & _
    "Please be advised that there is a document ready to be proofed :<br><B>" & _
    ActiveWorkbook.Name & "</B> is created.<br>" & _
    "Click on this link to open the file : " & _
    "<A HREF=""file://" & ActiveWorkbook.FullName & _
    """>Link to the file</A>" & _
    "<br><br>Regards," & _
    "<br><br>Account Management</font>"

    On Error Resume Next
    With OutMail
    .To = "[email protected]"
    .CC = ""
    .BCC = ""
    .Subject = Worksheets("TM Tracking Chart").Range("B6") & " Proofing & Editing"
    .HTMLBody = strbody
    .Display 'or use .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
    Else
    MsgBox "The ActiveWorkbook does not have a path, Save the file first."
    End If
    End Sub


    Last edited by ExcelShi; 06-15-2015 at 10:46 AM.

  4. #4
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: I need a macro code to

    use this:

    Please Login or Register  to view this content.
    you can replace the cells (6,2) by range("B6")
    Last edited by JoeFoot; 06-15-2015 at 10:51 AM.

  5. #5
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: I need a macro code to

    Thanks Joe & No problem...

    Yes, the question is a bit unclear... basically if I update the spreadsheet to send an auto email if ANY cell in column D =95.
    Then I want the value of column B, corresponding row to show up SOMEWHERE (anywhere) in the email body or subject line...

    I think the part I am missing has to do with tying the corresponding cells in that row.
    For example... Information on the Science Chapter of the Book I am proofing is all on row 3, when i update the status in column D to 95, it sends me an email... But the email is useless if it doesnt tell me which chapter i got the notification for... I need Science somewhere in that email to tell me to go proof the Science Chapter....

    Any help you all can provide will be greatly appreciated!!

  6. #6
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: I need a macro code to

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: I need a macro code to

    Also add code tags as per forum rules - Thx

  8. #8
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: I need a macro code to

    Apologies... Done.

  9. #9
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: I need a macro code to

    try this:

    Please Login or Register  to view this content.
    this will create a new email for each row that has D>95. Careful though, if you have plenty of those this will create tons of emails and might crash Excel.

    Note I placed Cells(i, 4) >= 95. If you the D column to be EXACTLY =95 just adjust the instructions

  10. #10
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: I need a macro code to

    THANKS JOE! This worked for the most part... I believe that the email is not generating because 95 is formatted as a percent in my spreadsheet... would you be able to help me with that??

  11. #11
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    I thought maybe attaching the spreadsheet to this thread would help?

    So if Column D reaches 95, generates an email, I just need the contents of the corresponding row's cell in column B to be the subject of the email.

    THANKS AGAIN!!
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    if formatted as a percent try > 0.95 instead of > 95

    To have this instance running only once when it sees the 1st row with D>95 then just add the instruction "Exit For" after "Set OutMail = Nothing"

  13. #13
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Joe, Looks like we are almost there!

    The 0.95 worked to identify the percentage....

    But the only problem now is when the email is generated... It only captures the subject title of the first row.

    I need the Title in Column B to populate the subject depending on the row cell that I change.


    So for instance...

    Row 1 - Science - 85% - CP
    Row 2 - Life Studies - 95% - SH
    Row 3 - Social Studies - 27% - DP

    Notice, Row 2 is at 95%, it sends me an email automatically, but I need the TITLE "Life Studies" as the subject line in the email.
    The way we have it coded now, no matter what row I change to 95% the title is always reading that first line "Science".


    Hope this helps...

    We're almost there!!!

    THANKS AGAIN JOE!!

  14. #14
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Would ANYONE be able to help me finish this??

  15. #15
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    that code works for me and I get different subject lines.

    Try removing the On Error Resume Next and see if you are hitting an error
    Got help? Pls give rep.
    If you do R&D learn VBA

  16. #16
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    I tried the exact code on post #9 with your example sheet (with cells(i,4)>0.95 instead of 95) and it created all the emails in your example with different subject lines.

    I only replaced:
    Please Login or Register  to view this content.
    with:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Thanks Joe, I just tried that too and its still only sending that first title no matter which trigger cell i update.

    I only want 1 email per trigger, so I used the "Set OutMail = Nothing" with "Exit For" behind it like you told me to do a few messages back. That worked perfectly.

    All I need now is SOMEWHERE in the email (doesnt HAVE to be the subject line, needs to tell me the value of cell B, depending on which cell in column D I update. Again, it doesnt have to be the subject line of the email, it can say it in the body of the email too...

    Here's where I am with my macro code now:

    Sub Make_Outlook_Mail_With_File_Link()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim i As Integer

    If ActiveWorkbook.Path <> "" Then
    Set OutApp = CreateObject("Outlook.Application")


    strbody = "<font size=""3"" face=""Calibri"">" & _
    "Quality Assurance Department:<br><br>" & _
    "Please be advised that there is a document ready to be proofed: .Cells(i, 2) <br><br>"

    For i = 1 To 140

    If Cells(i, 4) = 0.95 And IsNumeric(Cells(i, 4)) = True Then


    Set OutMail = OutApp.CreateItem(0)

    With OutMail
    .To = "[email protected]"
    .cc = ""
    .BCC = ""
    .Subject = ActiveWorkbook.Sheets("TM Tracking Chart").Cells(i, 2) & " Proofing & Editing"
    .HTMLBody = strbody
    .Display 'or use .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Exit For


    End If


    On Error GoTo 0
    Next i

    Set OutApp = Nothing
    Else
    MsgBox "The ActiveWorkbook does not have a path, Save the file first."
    End If
    End Sub

  18. #18
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    remove the Exit For

    You only need to run the macro once to get emails for every row that you have.

    The Exit For is for when you only want 1 email for the very first row you will encounter that is >0.95 and then exit the macro alltogether - which is not what you want.

    Running this macro just 1 time on the example file and with the Exit For removed gives me 9 emails with 9 different subject lines.
    Last edited by JoeFoot; 06-18-2015 at 06:09 PM.

  19. #19
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Joe this spreadsheet is basically to send one department an email when another department is complete with 1 line item.

    so i just want 1 email sent every time i run the macro.

    If Production department is done with Row 3, they mark it 95 % and it emails the quality department so they can take action.

    I dont want 9 emails going, there should be an email 1 time, 1 email.
    Science Chapter is written, the team updates it to 95%, macro runs and sends me an email letting me know WHICH Chapter is ready for the Quality Department.

    Does that make sense?

    I am doing this basically to let one department know its ok to begin an assignment without the other department having to tell them, there should only be one email sent at the time the column D is changed to 95%, the email shouldnt go again.

    Hope this helps

  20. #20
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Joe this spreadsheet is basically to send one department an email when another department is complete with 1 line item.

    so i just want 1 email sent every time i run the macro.

    If Production department is done with Row 3, they mark it 95 % and it emails the quality department so they can take action.

    I dont want 9 emails going, there should be an email 1 time, 1 email.
    Science Chapter is written, the team updates it to 95%, macro runs and sends me an email letting me know WHICH Chapter is ready for the Quality Department.

    Does that make sense?

    I am doing this basically to let one department know its ok to begin an assignment without the other department having to tell them, there should only be one email sent at the time the column D is changed to 95%, the email shouldnt go again.

    Hope this helps

  21. #21
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    ok so you don't want the macro to trigger every event that has 95%, you just want it to trigger the LAST cell to be changed to 95%.

    To do that you need to keep track of which emails were already sent. Do this then

    -> Add another column to your table termed "Email Sent?". Put it on column G.

    -> Use this code:

    Please Login or Register  to view this content.
    Whenever the cell is changed to 95%, call the macro. It will check all cells that have 0.95 and it will stop on the 1st one that does not have "Yes" in the email sent column. After generating the email, it will populate that column with a "Yes"

  22. #22
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    THIS WORKED PERFECTLY!! THANK YOU SOOOO MUCH JOE.

    It has been reviewed and all is a go... My last question, I would like to use the same column (D), when it equals 96% to send a return email to the email address located in cell T3 and instead of the macro recognizing the word "yes" to NOT send duplicate emails, can it recognize the word "Complete"???

    any information you can provide will be greatly appreciated. Below is the code I am now using:

    Option Explicit

    Sub Make_Outlook_Mail_With_File_Link()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim i As Integer

    If ActiveWorkbook.Path <> "" Then
    Set OutApp = CreateObject("Outlook.Application")


    strbody = "<font size=""3"" face=""Calibri"">" & _
    "Dept:<br><br>" & _
    "Please be advised that there is a document ready: <br><B>" & _
    ActiveWorkbook.Name & "</B><br>" & _
    "Click on this link : " & _
    "<A HREF=""file://" & ActiveWorkbook.FullName & _
    """>Tracking Chart</A>" & _
    "<br><br>Regards," & _
    "<br><br>TDS Project Management Team</font>"

    For i = 4 To 150

    On Error Resume Next

    If Cells(i, 4) = 0.95 And Cells(i, 17) <> "Yes" Then


    Set OutMail = OutApp.CreateItem(0)

    With OutMail
    .To = "[email protected]"
    .cc = ""
    .BCC = ""
    .Subject = ActiveWorkbook.Sheets("TM Tracking Chart").Cells(i, 2) & " is Ready to be Proofed"
    .HTMLBody = strbody
    .Display
    End With
    On Error GoTo 0

    Cells(i, 17) = "Yes"

    Set OutMail = Nothing

    Exit For

    End If

    On Error GoTo 0
    Next i

    Set OutApp = Nothing
    Else

    End If
    End Sub

  23. #23
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Sure, here it is:

    Please Login or Register  to view this content.
    this code will check if cell is 96% or higher and that column G does not have "Complete" on it. If both conditions check then it sends an email to the address listed on Cells T3 (row 3, column 20)

    After sending the email, it will place the word "Complete" in Column G

    If cell is not 96% or higher then it will check to see if it's 95%. If so the old part of the code will run.

    The code will exit after generating the email, weather a "Complete" email or a "Yes" email.

    See if that helps.

    Best of luck.

  24. #24
    Registered User
    Join Date
    06-12-2015
    Location
    Houston, TX
    MS-Off Ver
    MS Office 2010
    Posts
    14

    Re: Macro needed to send auto email with contents of cell on corresponding row as trigger

    Please see attached spreadsheet… I need assistance creating a macro that does the following 4 things:

    1. Send auto email to: [email protected] MONTHLY starting 6 months before EXPIRATION DATE (Column E). The body of the email, can just say REMINDER FOR (Same Row, Column A) that Certification Training (Same Row, Column B) is Due to Expire on (Same Row, Column C). Please renew or contact your supervisor as soon as possible.

    2. Once an e-mail is sent, I also need Column F (which is blank right now) to READ: “1 REMINDER SENT” at 6 months, “2 REMINDER SENT” at 5 months, “3 REMINDER SENT” at 4 months and so on… *Basically this column is to know how many auto e-mails were sent.


    3. Color Code the Cell in Column F. Fill the color of the cell in column F, depending on the following:
    - Reminders sent at 6 month & 5 month = Green Filled Cell
    - Reminders sent at 4 month & 3 month = Yellow Filled Cell
    - Reminders sent at 2 month & 1 month = Red Filled Cell

    4. For those who DO NOT COMPLETE their certification, I need ONE auto e-mail sent saying:

    “No information for (Same Row, Column A) – Training Titled (Same Row, Column B) has been received. Due Date Has Expired.”

    Excel will know to send this e-mail because Column C “Due Date”, will be todays Date and Column E in that same row will be blank.


    I need this macro as soon as possible. If anyone can help, it would mean tons for me!!! THANKS SO MUCH, I Look forward to hearing your responses.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to copy Code / Macro Code / 2 Sheets
    By paxile2k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-23-2014, 12:59 AM
  2. [SOLVED] Code to create Macro Button and Assigning Macro code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2014, 11:30 AM
  3. Unable to edit macro recording code to be a relative code.
    By holaitsme in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2014, 10:51 AM
  4. [SOLVED] Excel Macro Visual Basic code not looking at all sheets with second section of code.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2014, 08:26 AM
  5. [SOLVED] Code with last column and last row to recognize multiple commands through the macro code
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2014, 04:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1