• 0

Solved Autofilter Column Of Data Based On Cell Input

  • 0


I have a table of data which I would like to filter based on a manual cell input instead of the autofilter option.

The table is 10 columns wide, with a series of numbers in column F. I would like to filter the data for all data greater than or equal to a cell input corresponding to column F.

I have experience recording macros and can interpret VBA code but my ability to write code is very low.


1 Answer

  1. I am assuming that you have Column Headings for your table in Row 6, with data in F7:F3000.

    If that is true, try this…

    1 – Right-Click the sheet tab for the sheet that holds your table
    2 – Select View Code
    3 – Paste this code into the pane that opens
    4 – Enter a value in F2

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Autofilter Column F based on value in F2, Criteria ">="
       If Target.Address = "$F$2" Then
           ActiveSheet.Range("$F$6:$F$3000").AutoFilter _
                   Field:=1, Criteria1:=">=" & Range("F2")
       End If
    End Sub

    Please be aware that each time this code runs, your “undo” history will be erased. That happens anytime you run a macro.

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    • 0