ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Filter criteria (https://www.excelbanter.com/excel-discussion-misc-queries/57076-filter-criteria.html)

Tony

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



Bob Phillips

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





Roger Govier

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




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com