Ok so I'm going to try again
I know i need an if then statement, but I can't figure this out and have been stumped for a few days.
-
Option Explicit
-
'Needs Module 2 to set definitions for RAngeHTM so, both moduels needed
-
Sub Send_Row()
-
Dim OutApp As Object
-
Dim OutMail As Object
-
Dim cell As Range
-
Dim rng As Range
-
Dim Ash As Worksheet
-
-
Set Ash = ActiveSheet
-
On Error GoTo cleanup
-
Set OutApp = CreateObject("Outlook.Application")
-
-
With Application
-
.EnableEvents = False
-
.ScreenUpdating = False
-
End With
-
'This determines the email cell, and the lcase cell offset is the distance in # of cells away from this column, therefore you must specify the distance if any changes in columns are made
-
For Each cell In Ash.Columns("b").Cells.SpecialCells(xlCellTypeConstants)
-
If cell.Value Like "?*@?*.?*" And LCase(cell.Offset(0, 2).Value) = "yes" Then
-
'Use this to set range of Cells, as in what columns to put in
-
-
Ash.Range("A1:O100").AutoFilter Field:=2, Criteria1:=cell.Value
-
-
With Ash.AutoFilter.Range
-
On Error Resume Next
-
Set rng = .SpecialCells(xlCellTypeVisible)
-
On Error GoTo 0
-
End With
-
-
Set OutMail = OutApp.CreateItem(0)
-
-
On Error Resume Next
-
With OutMail
-
.To = cell.Value
-
.Subject = "IAT-Blanket Order"
-
.HTMLBody = RangetoHTML(rng)
-
.Display 'Or use Send
-
End With
-
On Error GoTo 0
-
-
Set OutMail = Nothing
-
Ash.AutoFilterMode = False
-
End If
-
Next cell
-
-
cleanup:
-
Set OutApp = Nothing
-
With Application
-
.EnableEvents = True
-
.ScreenUpdating = True
-
End With
-
End Sub
Here is my current code, but I was hoping to find a way to input a code that will allow me to either stop the email when lets say column f is greater thna column g, or even a notification of an error. Thanks, really appreciate it.