Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not filtering by date
hi Dave,
tried changing the code but still the same. it's showing results as far back as yr2003. My dates are entered in the dd/mm/yy format. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not filtering by date
hi Dave,
tried changing the code but still the same. it's showing results as far back as yr2003. My dates are entered in the dd/mm/yy format. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not filtering by date
Sometimes, I've changed the column with dates to be formatted as General.
Then did the filter and then later redid the formatting back to a nice date format. If that's too ugly, maybe you could insert a helper column and do the equivalent. chOcO wrote: hi Dave, tried changing the code but still the same. it's showing results as far back as yr2003. My dates are entered in the dd/mm/yy format. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Filtering by a date | Excel Discussion (Misc queries) | |||
Filtering by newest date | Excel Discussion (Misc queries) | |||
Need help filtering a date column | Excel Discussion (Misc queries) | |||
Not filtering by date | Excel Programming | |||
Filtering Names By Date | Excel Programming |