#1   Report Post  
Posted to microsoft.public.excel.misc
Tony
 
Posts: n/a
Default Filter criteria


I am trying to filter a list using two date criteria, so that the returned
results are the values in between.

I have found from Ron deBRuin's website the following code as part of a
macro to filter a spreadsheet using two criteria:

rng.Autofilter Field:=4, Criteria1:="=" & DateSerial(1947, 2,
23),_Operator:=xlAnd, Criteria2:="<=" & DateSerial(1988, 5, 7) '

This is doing exactly what I want except I need the two criteria to be
values in two cells on the spreadsheet.

Would anyone know how the code should be so that the two date criteria are
hard typed into the code but rather are taken from two populated cells on the
spreadsheet that the macro is filtering (the two cells are not in the list
being filtered).

Thanks
Tony


  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Filter criteria

rng.Autofilter Field:=4, Criteria1:="=" & Range("A1").Text, _
Operator:=xlAnd, Criteria2:="<=" & Range("A2").Text

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tony" wrote in message
...

I am trying to filter a list using two date criteria, so that the returned
results are the values in between.

I have found from Ron deBRuin's website the following code as part of a
macro to filter a spreadsheet using two criteria:

rng.Autofilter Field:=4, Criteria1:="=" & DateSerial(1947, 2,
23),_Operator:=xlAnd, Criteria2:="<=" & DateSerial(1988, 5, 7) '

This is doing exactly what I want except I need the two criteria to be
values in two cells on the spreadsheet.

Would anyone know how the code should be so that the two date criteria are
hard typed into the code but rather are taken from two populated cells on

the
spreadsheet that the macro is filtering (the two cells are not in the list
being filtered).

Thanks
Tony




  #3   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier
 
Posts: n/a
Default Filter criteria

Hi Tony

Try
rng.Autofilter Field:=4, Criteria1:="=" & Range("A1").Value, _
Operator:=xlAnd, Criteria2:="<=" & Range("B1").Value

Change A1 and B1 to suit.

Regards

Roger Govier


Tony wrote:
I am trying to filter a list using two date criteria, so that the returned
results are the values in between.

I have found from Ron deBRuin's website the following code as part of a
macro to filter a spreadsheet using two criteria:

rng.Autofilter Field:=4, Criteria1:="=" & DateSerial(1947, 2,
23),_Operator:=xlAnd, Criteria2:="<=" & DateSerial(1988, 5, 7) '

This is doing exactly what I want except I need the two criteria to be
values in two cells on the spreadsheet.

Would anyone know how the code should be so that the two date criteria are
hard typed into the code but rather are taken from two populated cells on the
spreadsheet that the macro is filtering (the two cells are not in the list
being filtered).

Thanks
Tony


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
How do I identify Filter criteria or variable graph title? Excel_loser Excel Discussion (Misc queries) 0 October 4th 05 07:07 PM
How do I show number of records that meet criteria filter CliffD Excel Discussion (Misc queries) 3 August 22nd 05 01:10 PM
Advanced filter and Criteria Range gearoid Excel Discussion (Misc queries) 2 July 20th 05 02:33 PM
advanced filter criteria "begins with" and "does not begin with" raph_baril Excel Worksheet Functions 3 June 28th 05 10:38 PM
Using advanced filter to search for criteria in a list Potatosalad2 Excel Discussion (Misc queries) 1 June 8th 05 03:08 AM


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

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

About Us

"It's about Microsoft Excel"