title: Auto-Filter Method Failing - Run-Time Error 1004
body: <p>How are you doing?</p>
  
  <p>Here's my question. I'm trying to apply an autofilter which the criterias are Dates that depends on which Quarter of the year we are. Here's the code.</p>
  
  <pre><code>If fator = 1 Then
      DataInicio = DateSerial(Year(Date), 10, 1)
      DataFinal = DateSerial(Year(Date), 12, 31)
  ElseIf fator = 2 Then
      DataInicio = DateSerial(Year(Date), 1, 1)
      DataFinal = DateSerial(Year(Date), 3, 31)
  ElseIf fator = 3 Then
      DataInicio = DateSerial(Year(Date), 4, 1)
      DataFinal = DateSerial(Year(Date), 6, 30)
  ElseIf fator = 4 Then
      DataInicio = DateSerial(Year(Date), 7, 1)
      DataFinal = DateSerial(Year(Date), 9, 30)
  End If
  
  wb.Sheets("Change-Order FUP").Activate
  
  If wb.Sheets("Change-Order FUP").AutoFilterMode = True And wb.Sheets("Change-Order FUP").FilterMode = True Then
      wb.Sheets("Change-Order FUP").ShowAllData
  ElseIf wb.Sheets("Change-Order FUP").AutoFilterMode = False Then
      wb.Sheets("Change-Order FUP").Cells(1, 1).AutoFilter
  End If
  
  wb.Sheets("Change-Order FUP").Range("A:P").AutoFilter Field:=5, Criteria1:="&gt;="&amp; DataInicio, Operator:=xlAnd, Criteria1:="&lt;=" &amp; DataFinal
  </code></pre>
  
  <p>I tried to use Criteria1 and Criteria2, both Criteria1, both Criteria2 and didn't work. Could someone give me a hand here?</p>
  
  <p>Thanks again for the support! Cheers</p>