Applying Filter on Button Click

mk_alii

New member
Joined
Jun 28, 2018
Messages
10
Reaction score
0
Points
0
Excel Version(s)
Excel 2013
Hello All,




I am trying to apply a filter from VBA code.




It's a table, named "AllProjectsOutstanding",

This table has 50-100 rows of data, maybe 40 of which contain actual data, the rest is filled with "."




Is there a way to apply a filter from VBA to upon a button click, or something just filter out all the data that contains "." (Column D; 1st Column in Table)
 
This can easily be done with the macro recorder.
Select the columns that contain your data.
Click on data, then filter.
Click on the filter drop down arrow in column d or your first column.
Click the drop down arrow for text filter then does not equal.
Use the drop down arrow to select ".".

Note in my worksheet "g" was the first column not "d".


Here is the code the macro recorder gave me.



Code:
Columns("G:I").Select
    Selection.AutoFilter
    ActiveSheet.Range("$G$1:$I$23").AutoFilter Field:=1, Criteria1:="<>.", _
        Operator:=xlAnd
You could then insert an active x command button & put this code in the command button.

You would probably need another button to unfilter your data.
 
Last edited:
Back
Top