title: For loop each visible row and set value at another column
body: <p>My code below has two parts. The first part basically sets a cell as a date that is 6 months from now. This part works but I'm having trouble with the second part.</p>
  <p>The second part is after filtering a table, I want to compare each cell in column H (which is a date value) with that future date in the first part. If the date in column H is <strong>after</strong> the future date, cell AI of that row will be set as &quot;Yes&quot;</p>
  <pre><code>Set Database = ThisWorkbook.Worksheets(&quot;Sheet1&quot;)
  Dim i As Long, LastRow As Long
  LastRow = Database.Cells(Rows.count, &quot;A&quot;).End(xlUp).Row
  
  With Database.Range(&quot;AI1&quot;)
  
      'Adds 6 months to today's date in cell AI1 in sheet
      .Formula = &quot;=EDATE(Today(),6)&quot;
      
      'Converts that date to 1st day of the month (e.g. 17/01/2020 is converted to 01/01/2020
      .Value = DateSerial(Year(Range(&quot;AI1&quot;)), Month(Range(&quot;AI1&quot;)), 1)
  
  End With
  
  For i = 2 To LastRow
  
      'This line throws a run-time error 13: type mismatch
      If Cells(i, &quot;H&quot;).SpecialCells(xlCellTypeVisible) &gt; Database.Range(&quot;AI1&quot;) Then
         
         Cells(i, &quot;AI&quot;).Value = &quot;Yes&quot;
         
      End If
   
  Next i
  </code></pre>