ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Filtering data based on formula (https://www.excelbanter.com/excel-discussion-misc-queries/184653-filtering-data-based-formula.html)

Krys

Filtering data based on formula
 
Hi, I want to filter a table of data to display rows with values between two
numbers but the numbers will change as it is used, so the criteria values
have to be in the form of a formula.

ie.

A1 = Manually inputted data (eg 1)
B1 = Manually inputted data (eg 7)

A2 = A1
B2 = B1

F7 = "Day"
F8-F12 = Data (eg 2, 5, 1, 4, etc)
G7, H7 etc more data

How do I filter F7:H12 with the criteria that values in column F are =A2
and =<B2?

Don Guillett

Filtering data based on formula
 
datafilterautofiltercustom
record a macro (and you may want to use "inputbox" instead of cell values
Sub Macro6()'recorded
'
' Macro6 Macro
' Macro recorded 4/22/2008 by Donald B. Guillett
'

'
Range("F2:H12").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="=2", Operator:=xlAnd, _
Criteria2:="<=5"
End Sub
better
Sub filterbyday()
Range("F2:H12").AutoFilter Field:=1, _
Criteria1:="=2", Operator:=xlAnd, Criteria2:="<=5"
End Sub
best
Sub filterbyday()
c1 = InputBox("Enter 1st")
c2 = InputBox("enter last")
Range("F2:H12").AutoFilter Field:=1, _
Criteria1:="" & c1, Operator:=xlAnd, Criteria2:="<" & c2
End Sub



--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Krys" wrote in message
...
Hi, I want to filter a table of data to display rows with values between
two
numbers but the numbers will change as it is used, so the criteria values
have to be in the form of a formula.

ie.

A1 = Manually inputted data (eg 1)
B1 = Manually inputted data (eg 7)

A2 = A1
B2 = B1

F7 = "Day"
F8-F12 = Data (eg 2, 5, 1, 4, etc)
G7, H7 etc more data

How do I filter F7:H12 with the criteria that values in column F are =A2
and =<B2?




All times are GMT +1. The time now is 06:22 AM.

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