+ Reply to Thread
Results 1 to 11 of 11

VBA Code to AutoFilter with dynamic Criteria

  1. #1
    Registered User
    Join Date
    08-01-2019
    Location
    Winnipeg
    MS-Off Ver
    Office 365
    Posts
    19

    VBA Code to AutoFilter with dynamic Criteria

    Hello Everyone,

    I have tried the following code which is not working for me.
    I believe there are multiple mistakes
    Can someone help me please?

    I am trying to Auto filter one column at a time based on the cell value in the header.
    Hopefully I can see all the filtered data without the need to scroll up.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by drgorantla; 11-01-2020 at 02:11 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VBA Code to AutoFilter with dynamic Criteria

    Perhaps
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-01-2019
    Location
    Winnipeg
    MS-Off Ver
    Office 365
    Posts
    19

    Re: VBA Code to AutoFilter with dynamic Criteria

    Hi jindon,
    Thanks a lot, your modifications are helping.
    I understood where I went wrong.
    Your modifications are filtering the first column based on the active cell value but when i run the same code second time its not filtering the cell values in the header of the next column
    I guess the AutoFilter Field should not be static here?
    Can you please have a look again?

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VBA Code to AutoFilter with dynamic Criteria

    Not clear about what you are trying to do.
    How do you want to filter?

  5. #5
    Registered User
    Join Date
    08-01-2019
    Location
    Winnipeg
    MS-Off Ver
    Office 365
    Posts
    19

    Re: VBA Code to AutoFilter with dynamic Criteria

    I apologize for not being clear.
    If we start with column D in the first row
    Auto filter criteria for Column D should be based on the active cell value (Value of cell D1)
    After filtering is complete the code should move to the next cell in the header, ie cell E1
    If we run the code again then Auto Filter should filter column E based on the cell value in E1 and move the next cell in the header

    Is this possible?

    thanks

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VBA Code to AutoFilter with dynamic Criteria

    One column at a time?
    I mean,
    1) filter one column and clear the filter and the 2nd column etc
    or
    2) filter 1st column and 2nd column and 3rd column till the last column altogether?
    1) you can see the last last column only filtered after the macro
    2) there is no filtered data after the macro in uploaded data.

  7. #7
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: VBA Code to AutoFilter with dynamic Criteria

    A very goof morning
    Could it be something like this perhaps
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-01-2019
    Location
    Winnipeg
    MS-Off Ver
    Office 365
    Posts
    19

    Re: VBA Code to AutoFilter with dynamic Criteria

    Hi Jindon,
    Yes, one column at a time, but when we go to the next column I may need to filter the already filtered data
    We do not want to clear the previous column filter.
    We should be able to stop filtering columns when ever we want
    I do not need to run the code until the last column always but I might have to if the situation demands
    Auto Filter field should be the first cell in the column and the criteria should be that cells value
    Is it possible?

    thanks
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VBA Code to AutoFilter with dynamic Criteria

    Then you can not do it via AutoFilter.
    AdvancedFilter
    Please Login or Register  to view this content.
    Edit: typo
    Last edited by jindon; 11-01-2020 at 04:03 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: VBA Code to AutoFilter with dynamic Criteria

    Any way!!
    May be
    Please Login or Register  to view this content.
    Last edited by mohadin; 11-16-2020 at 04:44 AM.

  11. #11
    Registered User
    Join Date
    08-01-2019
    Location
    Winnipeg
    MS-Off Ver
    Office 365
    Posts
    19

    Re: VBA Code to AutoFilter with dynamic Criteria

    Hello mohadin,
    I apologize if my request is confusing.
    Your code is taking the criterial from cell adjacent to the column we are trying to filter
    If we are filtering Column D then Criterial should not be (Row, Col + i)
    Is it possible to get rid of the message box so that i can run the code with keyboard shortcut for every column?

    I have learned something today from your code

    Thanks a lot

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Search & Find with AutoFilter code for Multiple Criteria Solved!
    By MattHamby in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2019, 08:40 AM
  2. Code issue with deleting rows using multiple criteria with autofilter
    By Ianmacros in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2019, 01:03 PM
  3. [SOLVED] VBA Code Autofilter criteria and row deletion not giving result
    By analystbank in forum Excel General
    Replies: 4
    Last Post: 02-09-2016, 02:29 AM
  4. Adding date criteria from text box to autofilter code
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2014, 04:26 PM
  5. Help with autofilter code with 2 criteria
    By lylegross in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-23-2014, 08:13 PM
  6. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  7. AutoFilter macro with dynamic criteria
    By juuck in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2008, 01:40 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1