Not do anything if Cell is blank

seasmith

New Member
Joined
Jul 6, 2011
Messages
44
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
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Is it not just:

Code:
ElseIf Range("L" & i) = "" Then
?

I don't really understand why its sending an e-mail if the cell is blank, the first If condition should prevent this?
 
Upvote 0
That did the trick. For some reason when I typed it in at first it was giving me an error but now it isn't. Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,484
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top