Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filtering by a date CR Excel Discussion (Misc queries) 3 February 18th 09 08:22 PM
Filtering by newest date Al Excel Discussion (Misc queries) 2 November 12th 08 05:05 PM
Need help filtering a date column Joe Miller Excel Discussion (Misc queries) 3 July 13th 06 12:51 AM
Not filtering by date chOcO Excel Programming 7 December 8th 04 01:24 AM
Filtering Names By Date Minitman[_2_] Excel Programming 3 February 23rd 04 05:23 PM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"