title: Excel VBA How to delete rows based on the value of a cell in a different worksheet
body: <p>I am trying to create a macro that will automatically delete rows from a raw data file based on multiple criteria.  I have been able to create a macro that will delete rows where certain columns have blank values, but I also need to delete rows that have a date that is equal or greater than a date contained in a specific cell in another worksheet. I have been all over the internet but have not found an explanation that addresses this particular case or one similar enough for me to figure it out.  I am working on automating a number of other reports, and this is the final piece that I need to be able to finish several of them.  Here is the code I am trying to use.</p>
  
  <pre><code> Sub Deletedatesbeyondreportmonth()
  
   Application.ScreenUpdating = False
  
   With ActiveSheet
  
      .AutoFilterMode = False
  
      .Columns("E").AutoFilter Field:=1, Criteria1:="&gt;= sheets("Sheet2").Range("C1")"
  
      .AutoFilter.Range.Offset(1, 0).EntireRow.Delete
  
      .AutoFilterMode = False
  
  End With
  
  End Sub
  </code></pre>
  
  <p>If I replace the criteria <code>sheets("Sheet2").Range("C1")</code> with the actual value that is contained in the specified cell the macro works, however I need it to be able to run based off the value contained in that cell.  I have played with some syntax variations and got different error messages, but haven't been able to figure it out.  If I run this as is, it highlights the word Sheet2 on the criteria line and says:</p>
  
  <blockquote>
    <p>Compile Error expected: End of statement</p>
  </blockquote>