Help: Send email to people where expiry date is missing in column H & I

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question

    Hi Guys, I am looking for some help in this . I am trying to send emails using VBA, in attach worksheet there are some email address written in column F. When i am pressing button "send email" email will be send to email address as in column f. I don't want to send email to all email address . If expiry date is present in both columns H & I then person should not receive email & if there is no date in any column H & I should receive email


    • Macro.xls

      (137.22 kB, downloaded 36 times, last: )
  • Have a try changing these 4 lines of code:

    1. '...
    2. Set rng = sh.Cells(cell.Row, 6).Range("C1:D1") '<= changed
    3. If cell.Value Like "?*@?*.?*" And _
    4. Application.WorksheetFunction.CountA(rng) < 2 Then '<= changed
    5. Set OutMail = OutApp.CreateItem(0)
    6. With OutMail
    7. .To = sh.Cells(cell.Row, 6).Value
    8. .Subject = WS.Range("B1").Value '<= changed
    9. .Body = WS.Range("B3").Value '<= changed
    10. '...
  • Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post. We are here to help so help us help you!

    Read this to understand why we ask you to do this