title: Using date variables in an AutoFilter Between statement
body: <p>I am trying to filter a spreadsheet between two dates input by the user.  The code that I've written (with major help from the auto macro tool in Excel) is:</p>
  
  <pre><code>Sub Between()
  Between Macro
  Filters Create-Date between two parameters.
  
  Dim MonthNeeded1 As Date, MonthNeeded2 As Date
  
  Let MonthNeeded1 = InputBox("First Day Of Month for Target Period", "Date", "mm/dd/yyyy")
  
  Let MonthNeeded2 = InputBox("Last Day Of Month for Target Period", "Date", "mm/dd/yyyy")
  
  ActiveSheet.Range("$A$1:$S$8704").AutoFilter Field:=4, Criteria1:= _"&gt;= MonthNeeded1", Operator:=xlAnd, Criteria2:="&lt;= MonthNeeded2"*
  
  End Sub
  </code></pre>
  
  <p>My problem seems to be with the Criteria1 and Criteria2 statements.  The string <code>MonthNeededX</code> is being put into the filter command instead of the variable date input by the user.  I've searched this site and others and can't seem to find the problem.  Can someone help?</p>