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
 

AD_Taylor

Well-known Member
Joined
May 19, 2011
Messages
687
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?
 

seasmith

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

Forum statistics

Threads
1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top