Results 1 to 6 of 6

Auto send email when condition is met

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-23-2007
    Location
    England
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2208 Build 16.0.15601.20072) 64-bit
    Posts
    102

    Auto send email when condition is met

    Hello All
    I am hoping you can help me with the below.

    What I want
    I have an excel spreadsheet containing a list of tasks that need completing. I have coded the sheet with formula to automatically indicate when items require an update (example attached). What I am after is for an automatic email to be sent to me for each item listed as ‘Update Required’. The body needs to contain the brief description of the item, so for example the ‘Update Required’ indicator is in column F and the item description is in column B, so would require something like ‘ActiveCell.Offset(-4,0)’ to select and copy the description.

    What I have
    Below is my attempt at the code required but it isn’t working right. This is what I want:
    • Email to only be sent for items listed as ‘Update Required’ in column F
    • Email to still work even when the worksheet is not open
    • Email body to contain the brief description contained in column B

    Spreadsheet condition trigger

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim Rcell As Range
    Dim i As Integer
    Set Rcell = Range("F16:F18")
    
    For Each Cell In Rcell
    If Target.Cells.Value = "" Then Exit Sub
     If Target.Cells.Value = "Update Required" Then
    ActiveCell.Offset(-4, 0).Copy
                Call Action_Required
                End If
            'End If
        Next Cell
    End Sub
    Email process
    Sub Action_Required()
    
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Dim RngCopied As Range
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        Set RngCopied = Selection
    
        strbody = "Check Daily Task sheet" & vbNewLine & vbNewLine & _
                  "as something needs a chase up"
    
        On Error Resume Next
        With OutMail
            .To = "[email protected]"
            .CC = ""
            .BCC = ""
            .Subject = "Chase up is required"
            .Body = strbody
            .HTMLBody = RngCopied
            .Send
                
            End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Appreciate this is a lot to ask but am grateful for any assistance I can receive

    Many thanks All
    G1
    Attached Files Attached Files

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 if a condition is true.
    By sn152 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-03-2022, 04:34 PM
  2. Condition on sendint email or not to send email by a yes no in a cell
    By toofani in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2015, 04:35 AM
  3. 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
  4. [SOLVED] auto send email help
    By laduk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2013, 05:53 AM
  5. Auto send email with the cell value that triggered the email in the first place.
    By coobey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2013, 05:40 PM
  6. [SOLVED] Help please with auto send email VBA, it was working but isn't now
    By nje in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2013, 11:03 AM
  7. 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

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