Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I identify Filter criteria or variable graph title? | Excel Discussion (Misc queries) | |||
How do I show number of records that meet criteria filter | Excel Discussion (Misc queries) | |||
Advanced filter and Criteria Range | Excel Discussion (Misc queries) | |||
advanced filter criteria "begins with" and "does not begin with" | Excel Worksheet Functions | |||
Using advanced filter to search for criteria in a list | Excel Discussion (Misc queries) |