Results 1 to 2 of 2

Thread: Applying Filter on Button Click

  1. #1
    Seeker mk_alii's Avatar
    Join Date
    Jun 2018
    Posts
    10
    Articles
    0
    Excel Version
    Excel 2013

    Applying Filter on Button Click



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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)

  2. #2
    Acolyte Heyjoe's Avatar
    Join Date
    Jan 2019
    Location
    USA
    Posts
    52
    Articles
    0
    Excel Version
    2019
    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 by Heyjoe; 2019-02-20 at 05:54 PM. Reason: need code brackets

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •