title: Stop macro if column is blank excel vba
body: <p>I have made some code but if the range R2:34 is blank, it will still open the template email with no data in him. Please tell me where am I doing the bad connection. </p>
  
  <pre><code>Sub 1()
      Dim OutApp As Object
      Dim OutMail As Object
      Dim sTo As String
      Dim spo As String
      Dim emailRng As Range, cl As Range, dtrecuta As Range
      Dim c As Range
  For Each cell In Cells.Range("N2:N34")
  If LCase(Cells(cell.Row, "N").Value) = "0" Or LCase(Cells(cell.Row, "N").Value) &lt; "480" Then
  On Error Resume Next
  Cells(cell.Row, "R").Value = Cells(cell.Row, "M").Value
  Else
  Cells(cell.Row, "R").Value = Null
  End If
  Next cell
      a = CLng(Date)
      Set emailRng = Worksheets("Sheet1").Range("r2:r34")
      Set dtrecuta = Worksheets("Sheet1").Range("P2")
      For Each cl In emailRng
          sTo = sTo &amp; ";" &amp; cl.Value
      Next
      sTo = Mid(sTo, 2)
          Set OutApp = CreateObject("Outlook.Application")
          Set OutMail = OutApp.CreateItemFromTemplate("C:\Users\Marius\AppData\Roaming\Microsoft\Templates\statistica.oft")
      On Error Resume Next
      With OutMail
          .To = sTo
          .CC = ""
          .BCC = ""
          .Subject = "TESTARE Statistica pentru data de " &amp; dtrecuta
          strbody = "Buna " &amp; " , " &amp; vbNewLine &amp; vbNewLine &amp; _
                    "Te rog sa trimiti statistica astazi " &amp; a &amp; " pana in ora 10:00, " &amp; _
                    " pentru data de " &amp; dtrecuta &amp; vbNewLine &amp; vbNewLine &amp; "O zi buna." &amp; _
                    " " &amp; vbNewLine &amp; vbNewLine &amp; " Acesta este un mesaj automat nu raspundeti la acest e-mail. "
          .Display
          .Body = strbody &amp; Signature
          .send
      End With
              On Error GoTo cleanup
              Set OutMail = Nothing
  cleanup:
      Set OutMail = Nothing
      Set OutApp = Nothing
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>