View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
chOcO chOcO is offline
external usenet poster
 
Posts: 8
Default Not filtering by date

i've tried the code below but it does not seems to filter out the
recent 2 weeks entries. Kinda stumped here and will appreciate any
help. Thanks!

Private Sub filterp_Click()

Dim Class As String
Dim FilterRange As Range
Dim myDate As Date
Class = ComboBox1.Value

myDate = Format(Date - 14, "dd/mm/yy")
Range("A1").Select
Selection.AutoFilter
Set FilterRange = ActiveSheet.Range("A1:AK" & _
ActiveSheet.Range("A65536").End(xlUp).Row)
FilterRange.AutoFilter Field:=1, Criteria1:=Class, Operator:=xlAnd, _
Field:=9, Criteria1:="=" & myDate

End Sub