Filtering data based on formula

  • Thread starter Thread starter Krys
  • Start date Start date
K

Krys

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?
 
data>filter>autofilter>custom>
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
 
Back
Top