I have this code:
For i = 7 To 2000
If Range("L" & i) <= (Date - 365 * (3 * Range("N" & i))) - 182 Then
Address = Cells(i, 15)
strbody = "Relief Valve number " & Cells(i, 1) & " at " & Cells(i, 2) & blank & Cells(i, 3) & Cells(i, 4) & " needs to be tested"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Address
.CC = ""
.BCC = ""
.Subject = "Retest Pressure Relief Valve"
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
.Send 'Sends Email
End With
On Error GoTo 0
End If
Next i
The code sends an email if the if statement is true. I need to change the If to and elseif and put an if statement infront that says if the cell is blank to not send an email. I have had no success so far. Please help
i tried doing:
If Range("L" & i) <= (Date - 365 * (3 * Range("N" & i))) - 182 = " " Then
but it didn't work
For i = 7 To 2000
If Range("L" & i) <= (Date - 365 * (3 * Range("N" & i))) - 182 Then
Address = Cells(i, 15)
strbody = "Relief Valve number " & Cells(i, 1) & " at " & Cells(i, 2) & blank & Cells(i, 3) & Cells(i, 4) & " needs to be tested"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Address
.CC = ""
.BCC = ""
.Subject = "Retest Pressure Relief Valve"
.Body = strbody
.Attachments.Add ActiveWorkbook.FullName
.Send 'Sends Email
End With
On Error GoTo 0
End If
Next i
The code sends an email if the if statement is true. I need to change the If to and elseif and put an if statement infront that says if the cell is blank to not send an email. I have had no success so far. Please help
i tried doing:
If Range("L" & i) <= (Date - 365 * (3 * Range("N" & i))) - 182 = " " Then
but it didn't work