title: VBA comparing two dates
body: <p>I know it sounds like a simple task but I've been trying various approach and still didn't get success yet.</p>
  
  <ol>
  <li><p>I have a big data set with many variables and two of them are of use. First is called "symbol" (aaa,bbb,ccc,etc) and second is "date" (e.g. 2012-05-15 20:00); One symbol corresponds to multiple dates;</p></li>
  <li><p>I wanted to delete some symbols with specific date (e.g., bbb, 2012-05-15) and I have the list of deleting symbols;</p></li>
  <li><p>I was trying to compare the date in dataset and the deleting date in a for loop and to delete the entire row if there equal to each other for specific symbol and that's where the problem is;</p></li>
  <li><p>The code is below:</p>
  
  <pre><code>Dim d1 As Date
  d1 = DateSerial(2012, 5, 15) 'This is the deleting date  
  MsgBox (IsDate(d1)) 'This returns true   
  MsgBox (IsDate(DateValue(Cells(4, 9)))) 'This returns true
  
  For j = lastRow To 2 Step -1  
     If Cells(j,2).Value = "bbb" And (CDate(d1) = DateValue(Cells(j, 9))) Then Rows(j).EntireRow.Delete  
  Next
  </code></pre></li>
  <li><p>VBA gave me "type mismatch" error. I also tried If d1 = DateValue(Cells(j,9)) Then Rows(j).EntireRow.Delete but this didn't work either. The screenshot has the value in the cell, when it raises the error.</p>
  
  <p><img src="https://i.stack.imgur.com/VPJtC.png" alt="The screenshot has the value is in the cell, when it raises the error"></p></li>
  </ol>