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...
Bookmarks