Results 1 to 8 of 8

Email macro will not read from my table

Threaded View

  1. #1
    Registered User
    Join Date
    09-22-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    11

    Unhappy Email macro will not read from my table

    I need help. I've been at this too long by myself. I can't find the solution, I'm just not that competent when it comes to VBA.

    My issue here is that I have a macro that will send a small email message to each participant within the list. The VBA code works correctly in a worksheet that does not have formulas or links within them. I've tested it in other work sheets with just the four cells I'm referencing in the VBA code. I do not know how to make the code read the Text only within the cell opposed to the Value. I believe that is where the VBA code is breaking.

    The Code:
    For Example it reads 4 cell values, determining whether or not to generate an email based off of "yes" and "send" in the last two cell. Works well with non-formula cells and in Cells A through D for test purposes, just not in mine at the moment.

    I've had to create this all encompassing Table so it can grow and be used by others at work, so it has to be pretty dummy-proof in case I'm not available lol. That is why the cells and there formulas are the way they are, as I will 'hide' most of the Columns from their views.

    The code:

    Sub Test2()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("Q").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
    LCase(Cells(cell.Row, "R").Value) = "yes" _
    And LCase(Cells(cell.Row, "S").Value) <> "send" Then

    Set OutMail = OutApp.CreateItem(0)

    strbody = "Hello " & Cells(cell.Row, "P").Value _
    & vbNewLine & vbNewLine & _
    "This is line 1" & vbNewLine & _
    "This is line 2" & vbNewLine & _
    "This is line 3" & vbNewLine & _
    "This is line 4"

    On Error Resume Next
    With OutMail
    .To = cell.Value
    .CC = ""
    .BCC = ""
    .Subject = "Report Reminder"
    .Body = strbody

    .Display
    End With
    On Error GoTo 0
    Cells(cell.Row, "D").Value = "send"
    Set OutMail = Nothing
    End If
    Next cell

    cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
    End Sub



    I've also attached a sample of the excel sheet if would like to see or edit in there.

    I'd appreciate anything at this point, I just don't get it...
    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. Macro to email set of cells as table that runs every 30 minutes
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2013, 08:53 AM
  2. Macro to email reports out of a Pivot Table. Help!
    By AllExcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2012, 05:32 PM
  3. Macro: open file, read data, create table, vlookup
    By doctorspears in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2011, 12:54 PM
  4. outlook macro to pull in a table from excel file to email.
    By chewwy in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2009, 03:10 PM
  5. email a read only doc
    By Vlegg in forum Excel General
    Replies: 1
    Last Post: 05-11-2006, 03:00 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