Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Filter between dates

I recorded a macro that would filter the dates in column A between two
dates. I looked at the code and made some edits and came up with this after
a little bit of tweaking:

Sub ChangeWeek()

Dim weekbegin As Date
Dim weekend As Date

weekbegin = InputBox("Week Beginning")
weekend = InputBox("Week Ending")
Selection.AutoFilter Field:=1, Criteria1:=weekbegin, Operator:=xlOr _
, Criteria2:=weekend

End Sub

Only problem is that the code above only shows me those 2 dates. I need the
dates in between too.

I know its something simple, but I cant figure it out. Any help would be
cool.

Thanks
Niq


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Filter between dates

Use the And operator, and = and <= for the date operators:

Selection.AutoFilter Field:=1, _
Criteria1:="=" & weekbegin, Operator:=xlAnd, _
Criteria2:="<=" & weekend


Dominique Feteau wrote:
I recorded a macro that would filter the dates in column A between two
dates. I looked at the code and made some edits and came up with this after
a little bit of tweaking:

Sub ChangeWeek()

Dim weekbegin As Date
Dim weekend As Date

weekbegin = InputBox("Week Beginning")
weekend = InputBox("Week Ending")
Selection.AutoFilter Field:=1, Criteria1:=weekbegin, Operator:=xlOr _
, Criteria2:=weekend

End Sub

Only problem is that the code above only shows me those 2 dates. I need the
dates in between too.

I know its something simple, but I cant figure it out. Any help would be
cool.

Thanks
Niq




--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Filter between dates

i knew it was easy.

thanks
niq

"Debra Dalgleish" wrote in message
...
Use the And operator, and = and <= for the date operators:

Selection.AutoFilter Field:=1, _
Criteria1:="=" & weekbegin, Operator:=xlAnd, _
Criteria2:="<=" & weekend


Dominique Feteau wrote:
I recorded a macro that would filter the dates in column A between two
dates. I looked at the code and made some edits and came up with this
after a little bit of tweaking:

Sub ChangeWeek()

Dim weekbegin As Date
Dim weekend As Date

weekbegin = InputBox("Week Beginning")
weekend = InputBox("Week Ending")
Selection.AutoFilter Field:=1, Criteria1:=weekbegin, Operator:=xlOr _
, Criteria2:=weekend

End Sub

Only problem is that the code above only shows me those 2 dates. I need
the dates in between too.

I know its something simple, but I cant figure it out. Any help would be
cool.

Thanks
Niq



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



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
Filter in between dates Linda RQ New Users to Excel 6 November 3rd 09 01:14 AM
Filter Dates? Ken Excel Discussion (Misc queries) 4 February 20th 07 09:27 PM
How to filter out all the partial dates from a big list of dates? Tiwarr Excel Discussion (Misc queries) 1 September 14th 06 05:35 PM
how to filter dates? abigail New Users to Excel 2 August 18th 05 12:45 AM
Filter 'From' 'To' Dates in 1 Col John Childs[_3_] Excel Programming 3 August 26th 04 02:08 PM


All times are GMT +1. The time now is 12:30 AM.

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"