title: Send email if today's date is within four days of a due date
body: <p>I would definitely be considered a vba beginner, and I am trying to build into my project management spreadsheet an automatic email reminder when today's date falls within 4 days of a due date. But the code I'm using keeps returning a runtime error 13: type mismatch.</p>
  
  <p>I have searched the hallowed halls of the entire internet looking for this solution but nothing seems to match my specific problem, or maybe I'm just having trouble applying the principles in other posts to this specific code.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>Option Explicit
  
  Sub email()
  
      Dim r As Range
      Dim cell As Range
  
      Set r = Range("D4:D154")
  
      For Each cell In r
  
      If r.Value &lt;= (Date + 4) And r.Value &gt;= (Date + 0) Then
  
          Dim Email_Subject, Email_Send_From, Email_Send_To, _
          Email_Cc, Email_Bcc, Email_Body As String
          Dim Mail_Object, Mail_Single As Variant
  
          Email_Subject = ActiveCell(0, 2) &amp; ActiveCell(0, -2) &amp; "is due"
          Email_Send_From = "me@domain.com"
          Email_Send_To = Cells(1, 11)
          Email_Body = "This is an automated reminder to update BSA Project Manager on your project."
  
          On Error GoTo debugs
          Set Mail_Object = CreateObject("Outlook.Application")
          Set Mail_Single = Mail_Object.CreateItem(0)
          With Mail_Single
          .Subject = Email_Subject
          .To = Email_Send_To
          .Body = Email_Body
          .send
          End With
  
      End If
  
  Next
  </code></pre>
  
  <p>The error is being returned on the If r.value &lt;= (date+4) line. I included the entire code  both for context and for if anyone in passing sees anything else  I did that was wrong, that it may be pointed out if you are so inclined.</p>
  
  <p>I have attempted to use DateDiff as well with the same result. I'm thinking that maybe I shouldn't set Dim r as Range, or maybe I should be using some language to let excel know that what is in each cell in the D column is a date so that the data types match.</p>
  
  <p>Forgive me if this is an idiot question.</p>