Results 1 to 2 of 2

Email alert based on condition, VBA

Threaded View

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Medias, Romania
    MS-Off Ver
    Excel 2011
    Posts
    6

    Email alert based on condition, VBA

    Hello all, I am trying to send an email with all things I must change to my car. In row A I have the condition (yes or no).
    So if cell value in row A (I set range A2:A4 for now) is "yes" then the code sends an email to a specific mailbox with text from cell B2.
    The excel looks like this:
    A B
    Implement change Change description
    yes change tires
    no change oil
    yes change filters

    What I did so far:

    Sub Button1_Click()
    
        Dim r As Range
        Dim cell As Range
    
        Set r = Range("A2:A4")
    
        For Each cell In r
    
            If cell.Value = "yes" Then
    
                Dim Email_Subject, Email_Send_From, Email_Send_To, _
                Email_Cc, Email_Bcc, Email_Body As String
                Dim Mail_Object, Mail_Single As Variant
    
                Email_Subject = "subject"
                Email_Send_From = "----"
                Email_Send_To = "----"
                Email_Body = Range("B2")
    
                On Error GoTo debugs
                Set Mail_Object = CreateObject("Outlook.Application")
                Set Mail_Single = Mail_Object.CreateItem(0)
                With Mail_Single
                .Subject = Email_Subject
                .To = Email_Send_To
                .Body = Email_Body
                .send
                End With
    
            End If
    
        Next
    
    
        Exit Sub
    debugs:
            If Err.Description <> "" Then MsgBox Err.Description
    End Sub
    the code as it is only writes me an email with only text from cell B2 -> Email_Body = Range("B2")
    My blocking point is, I want all values from column B, not just one value, any suggestions what should I put instead Email_Body = Range("B2"),

    Thank you.
    Last edited by Ashrak; 06-07-2019 at 05:44 AM. Reason: more accurate request

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Email alert not firing with created macro even though the condition is satisfied.
    By sarat47 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-13-2017, 07:23 PM
  2. rule to send an email alert to another email address
    By wayneg in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 02-08-2016, 06:15 PM
  3. Looking to alert/email certain people on certain dates based on excel data
    By Wooodd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2015, 08:52 AM
  4. [SOLVED] Creating an alert based on a surpassed condition
    By clabhart in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-19-2014, 03:43 PM
  5. Replies: 0
    Last Post: 10-10-2013, 05:14 AM
  6. Code How to show alert messages with the IF condition based on other cell value
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2013, 09:51 PM
  7. [SOLVED] triggering an email alert from within a spreadsheet based upon a d
    By just-curious---george in forum Excel General
    Replies: 0
    Last Post: 03-23-2006, 09:45 PM

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