PC Review


Reply
Thread Tools Rate Thread

Custom Filter by Daterange or Month

 
 
dd
Guest
Posts: n/a
 
      5th Apr 2007
I want to filter a column of data by a date range or month and allow the
user to enter a beginning and end date (or a month number). U using the
record macro button I have created the following macro.

Sub OPI_FilterbyTargetDate()
'
' OPI_FilterbyTargetDate Macro
' Macro recorded 05/04/2007 by Dylan D

Selection.AutoFilter Field:=22, Criteria1:="=30/04/2007",
Operator:=xlAnd
End Sub

I want to bring up the custom filter dialog box to allow the user to enter a
date range.
How do I remove the text "Criteria1:="=30/04/2007"" and allow the user to
enter their own date range e.g., greater than 01-01-04 and less than
30-01-04.

Is there an easier way which will allow the users to enter the month number?

D Dawson



 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      5th Apr 2007
I think you're going to have to design your own input form using a userform
in the VBE. That will be some work as you'll have to parse/validate user
entries and then feed the dates into your macro. Personally I'd try to
train the users to use the built-in tools directly, if at all possible.

--
Jim
"dd" <dd.dd> wrote in message
news:%(E-Mail Removed)...
|I want to filter a column of data by a date range or month and allow the
| user to enter a beginning and end date (or a month number). U using the
| record macro button I have created the following macro.
|
| Sub OPI_FilterbyTargetDate()
| '
| ' OPI_FilterbyTargetDate Macro
| ' Macro recorded 05/04/2007 by Dylan D
|
| Selection.AutoFilter Field:=22, Criteria1:="=30/04/2007",
| Operator:=xlAnd
| End Sub
|
| I want to bring up the custom filter dialog box to allow the user to enter
a
| date range.
| How do I remove the text "Criteria1:="=30/04/2007"" and allow the user to
| enter their own date range e.g., greater than 01-01-04 and less than
| 30-01-04.
|
| Is there an easier way which will allow the users to enter the month
number?
|
| D Dawson
|
|
|


 
Reply With Quote
 
Art Farrell
Guest
Posts: n/a
 
      6th Apr 2007
Hi DD,

Another way would be to enter your minimum date in a cell, say AA1,
and your max date in a second cell, AB1. Then change your macro statement
to:

Selection.AutoFilter Field:=1, Criteria1:=">=" &
CDate(Range("AA1")), _
Operator:=xlAnd, Criteria2:="<=" & CDate(Range("AB1"))

CHORDially,
Art Farrell

"dd" <dd.dd> wrote in message
news:%(E-Mail Removed)...
> I want to filter a column of data by a date range or month and allow the
> user to enter a beginning and end date (or a month number). U using the
> record macro button I have created the following macro.
>
> Sub OPI_FilterbyTargetDate()
> '
> ' OPI_FilterbyTargetDate Macro
> ' Macro recorded 05/04/2007 by Dylan D
>
> Selection.AutoFilter Field:=22, Criteria1:="=30/04/2007",
> Operator:=xlAnd
> End Sub
>
> I want to bring up the custom filter dialog box to allow the user to enter

a
> date range.
> How do I remove the text "Criteria1:="=30/04/2007"" and allow the user to
> enter their own date range e.g., greater than 01-01-04 and less than
> 30-01-04.
>
> Is there an easier way which will allow the users to enter the month

number?
>
> D Dawson
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter out unique additions month to month Rookie_User Microsoft Excel Misc 3 13th Mar 2009 02:29 PM
Button to navigate/Filter records from month to month and year to Silvio Microsoft Access Form Coding 1 20th Jan 2009 09:41 PM
check if a a date is in a specified daterange H. Nissen Microsoft Excel Worksheet Functions 4 30th Oct 2008 09:20 PM
DAO QueryDef DateRange Al Camp Microsoft Access 3 30th Mar 2006 08:51 PM
Autocolor cells according to a DateRange vicber Microsoft Excel New Users 3 16th Mar 2004 01:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.