Closed Thread
Results 1 to 16 of 16

Send email if a condition is true.

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Send email if a condition is true.

    Hi All,

    I have a workbook which has data upto column N.

    Column J has got the email IDs.
    Column A has got the Item IDs.
    Column M shows the age if each item ID.
    Column N shows whether the age of item ID is greater than 1.

    Now what I want to do is to automatically send emails for the Item IDs which have the age greater than 1 to the respective persons email ids listed in column J.

    If one person is working on multiple Item IDs only single email should be sent listing all the Item Ids worked by that person.
    Note: Email IDs might change everytime.

    I have attached the sample workbook.
    Please help me on this.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    Will you be using Outlook?
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    Hi,

    Yes. I am using outlook.

    Thanks!

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    Try the Code in the attached...CTRL + x will fire the Code.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    Hi jaslake,

    Thanks for your reply. But this code is sending emails to all the email id, even if column N is showing as False. But I want iot to send emails only if the column N is showing True.

    Please help me on this.

    Thanks!

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    When I run the Code the Code it generates 5 Emails as follows:

    Email True Item
    John 3
    dorothy 8
    mick 3
    Raja 3
    mark 3
    Last edited by jaslake; 02-25-2015 at 12:16 PM. Reason: Remove Email Addresses

  7. #7
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    Hi jaslake,

    Yes it is generating 5 emails as you said. But what I want is it should generate email only for the rows for which the column N shows as "TRUE".

    Please help me.

    Thanks!

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    These are the Emails I get when running the Code on your Sample File..
    Attached Images Attached Images

  9. #9
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    Hi jaslake,

    I have a question. rows that have the status in column N as True, might change everday. In that case, will this code send emails only to the rows that have the status as True in Column N?

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    That's correct. This Line of Code Filters Column N for a value of TRUE and includes in the Email only those items.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    Hi jaslake,

    Yes. But I have a problem here. For example, when the first 10 rows have the status as True in column N and all other rows after 10th row has the status as false in column N, still it is generating empty emails.

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    Hi sn152

    On the Test File you attached or a different File?

    If a different File, I believe I know what's happening.

    Change this Line of Code.
    From
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.
    Let me know.
    Last edited by jaslake; 02-27-2015 at 02:18 PM.

  13. #13
    Registered User
    Join Date
    02-26-2014
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Send email if a condition is true.

    WOW. Super cool.. This works fine. Thank you so much jaslake...

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send email if a condition is true.

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    If this resolves your issue please mark your Thread as SOLVED.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  15. #15
    Registered User
    Join Date
    10-15-2020
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    5

    Re: Send email if a condition is true.

    Gents, please can you share the working file. I would like to apply the VBA code to my own worksheet if possible.

    Many thanks,
    Ken

    (Excel Fiend)

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,725

    Re: Send email if a condition is true.

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Send email with cell info if true
    By Shallak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2014, 02:04 PM
  2. VBA macro to send an email based on some condition.
    By santoshch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-21-2014, 11:30 PM
  3. Send email to recipitent address which is in a cell, if cell CHANGES to true
    By shiftyspina in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2014, 01:05 PM
  4. Excel to automatically send an email from Outlook when a condition is met
    By Spyke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2011, 04:40 AM
  5. [SOLVED] if condition is true than send info to another work sheet
    By jwpmann in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2005, 05:05 AM

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