I'm very new to the VBA world and could use a bit of help. I build a macro (probably not very efficient) that sends an email if column "N" is "yes". It worked perfectly this morning and for some reason, I can't get it to play nice. Could someone much smarter than I please take a look and let me know if I'm overlooking something?
Dim OutApp As Object
Dim OutMail As Object
Dim Tocell As Range
Dim CCCell As Range
Dim SigString As String
Dim Signature As String
Dim myRange As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
If Dir(SigString) <> "" Then
Else
Signature = ""
End If
On Error GoTo cleanup
Set myRange = ActiveSheet.Columns("K:K")
For Each Tocell In Columns("K").Cells.SpecialCells(xlCellTypeConstants)
For Each CCCell In Columns("P").Cells.SpecialCells(xlCellTypeConstants)
If Tocell.Value Like "?*@?*.?*" And _
LCase(Cells(Tocell.Row, "N").Value) = "yes" Then
If CCCell.Value Like "?*@?*.?*" And _
LCase(Cells(CCCell.Row, "N").Value) = "yes" Then
Set OutMail = OutApp.CreateItem(0)
SendKeys "^[ENTER}"
With OutMail
.to = Tocell.Value
.cc = CCCell.Value
.Subject = Cells(Tocell.Row, "G").Value
.Body = "Hello, " & vbNewLine & vbNewLine & _
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
End If
End If
Next CCCell
Next Tocell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Bookmarks