Not filtering by date
Sometimes working with the value of the dates makes life easier:
Private Sub filterp_Click()
Dim Class As String
Dim FilterRange As Range
Dim myDate As Date
Class = ComboBox1.Value
myDate = Date - 14 'no need to format it
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:="=" & clng(myDate) '<-- note the clng() change
End Sub
chOcO wrote:
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
--
Dave Peterson
|