title: Filter excel spreadsheet by month and year
body: <p>So I need to find the max price and min price for each month of each year.</p>
  
  <pre><code>Sub Anaylze()
  Dim datemonthcount As Long
  Dim dateyearcount As Long
  Dim yearcount As Long
  Dim month As Long
  Dim yearstart As Long
  Dim maxprice As Long
  Dim minprice As Long
  Dim rowprice As Long
  Dim percentchange
  
  Dim counterlong As Integer
  
  rowprice = 1
  yearstart = 2002
  counterlong = 0
  
      Range("A1").Select
      Do Until IsEmpty(ActiveCell) Or ActiveCell.Value = 0 Or IsNumeric(ActiveCell) = False
          counterlong = counterlong + 1 'Increments the counter
           If year(ActiveCell.Text) &lt;&gt; year((ActiveCell.Offset(-1, 0).Text)) Then
           dateyearcount = dateyearcount + 1
           End If
           ActiveCell.Offset(1, 0).Select ' Step down 1 row from present location.
      Loop
  
      For yearcount = 0 To dateyearcount
      For month = 1 To 12
      'Range("A1", "B" &amp; counterlong).AutoFilter Field:=1, Criteria1:="&gt;=" &amp; month &amp; "/01/" &amp; yearstart, Operator:=xlAnd, Criteria2:="&lt;=" &amp; month &amp; "/31/" &amp; yearstart
      maxprice = WorksheetFunction.Max(Range("A1", "B" &amp; counterlong).AutoFilter(Field:=1, Criteria1:="&gt;=" &amp; month &amp; "/01/" &amp; yearstart, Operator:=xlAnd, Criteria2:="&lt;=" &amp; month &amp; "/31/" &amp; yearstart))
      minprice = WorksheetFunction.Min(Range("A1", "B" &amp; counterlong).AutoFilter(Field:=1, Criteria1:="&gt;=" &amp; month &amp; "/01/" &amp; yearstart, Operator:=xlAnd, Criteria2:="&lt;=" &amp; month &amp; "/31/" &amp; yearstart))
      Cells(rowprice, "g") = maxprice
      Cells(rowprice, "h") = minprice
      rowprice = rowprice + 1 
      Next
      yearstart = yearstart + yearcount
      Next
  
  End Sub
  </code></pre>
  
  <p>My biggest issue is trying to get the filter to work, my data is formatted in this manner</p>
  
  <pre>10/26/2012   61.66
  10/25/2012   61.6</pre>