title: EXCEL VBA find max date and filter x days before max date
body: <p>I have excel sheet with dates in column A, and I need to find latest date and filter last 7 days before that latest date.
  I only found vba codes online which takes todays date - 7 days but I cant use that because these dates are from last year.</p>
  
  <p>Please and thank you!</p>
  
  <p>EDIT: </p>
  
  <p>Thanks for your suggestion.
  I tried to put it in my vba code but it filters 0 results.</p>
  
  <pre><code>Sub Filter()
      Dim maxDate As Date
      maxDate = WorksheetFunction.Max(ActiveSheet.Range("A:A"))
      ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
          "&gt;" &amp; maxDate - 6
  End Sub
  </code></pre>
  
  <p>Doesn't work since this VBA macro filers date by dd.mm.yyyy.  (NOTE THE DOT at the end), 0 results in my case, it should filter by dd.mm.yyyy (without dot). I dont know how to filter without dot</p>
  
  <p>EDIT2: This worked for me.</p>
  
  <pre><code>Sub Largest()
      Dim rng As Range
      Dim dblMax As Double
      Set rng = ActiveSheet.Range("A:A")
      dblMax = Application.WorksheetFunction.Max(rng)
      ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:= _
              "&gt;" &amp; dblMax - 7, Operator:=xlAnd
  End Sub
  </code></pre>