Auto Filtering a Table of Data by Typing a Filter Value Outside the Table

AJKim94

New Member
Joined
Jul 30, 2014
Messages
2
Hi,

I have a table of numerical and textual data. I would like to filter the table by the number values in column F7:F3000.

I am aiming to type any number, i.e. 0.30, in cell F2 and filter column F7:F3000 for all values greater than or equal to 0.30. It is important that cell F2 is dynamic, i.e. i can type any number into it and get a filter for all values greater than or equal to the input, and I can also delete the number inside of it and the table will reset.

I have experience recording macros and interpreting code but my ability to write code is limited.

Thank you,
AJ
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)    
    If Target.Column = 6 And Target.Row = 2 Then
        ActiveSheet.Range("$A$7:$Z$3000").AutoFilter Field:=6, Criteria1:=">=" & Cells(Target.Row, Target.Column).Value, _
        Operator:=xlAnd
    End If
End Sub

Assumptions made:

Your data goes from A:Z
Your data is already filtered, and will always be filtered
Your data max is static at 3000

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim rowStart As Long
    Dim rowEnd As Integer
    
    Dim colStart As Integer
    Dim colEnd As Long
    
    rowStart = 7
    colStart = 1
    With ActiveSheet
        colEnd = .Cells(7, Columns.count).End(xlToLeft).Column
        rowEnd = .Cells(Rows.count, "F").End(xlUp).Row
    End With


    
    
    If Target.Column = 6 And Target.Row = 2 Then
        Range("F7").Select
        Selection.AutoFilter
        ActiveSheet.Range(Cells(rowStart, colStart), Cells(rowEnd, colEnd)).AutoFilter Field:=6, Criteria1:=">=" & Cells(Target.Row, Target.Column).Value, _
        Operator:=xlAnd
    End If
End Sub

Assumptions made...not a lot on this one. Just be sure to change your rowStart and colStart if they're wrong.
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top