+ Reply to Thread
Results 1 to 11 of 11

Need Combo Box to Filter Rows

  1. #1
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Need Combo Box to Filter Rows

    Good morning!

    I need help with VBA code to filter an Excel Table to show only rows that contain "x" in the chosen column of an ActiveX Combo Box?

    For example (see attached), the table has one column for each month. An "x" appears in one or more of the months. When I choose "May" from the dropdown list I want to filter the table to show only rows where and "x" appears in the May column.

    What complicates this is that many rows contain an "x" in multiple month columns.

    Any suggestions would be most appreciated.

    Thanks,
    tom
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Need Combo Box to Filter Rows

    Here try this in Shee1 module. Though I'd suggest using Data Validation instead of Combobox on the sheet (and putting control above the data range).

    Please Login or Register  to view this content.
    Attached Files Attached Files
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    Hi CK76,

    Thanks for the help!

    I wonder if the code could be modified so that the filtering happens instantly instead of having the user click away from the combo box.

    Also, I would love to get your input on how this need could be achieved with data validation.

    Thanks again.
    tom

  4. #4
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    Oops...one more thing. What needs to be done to get back to the full list without filtering. That would be the starting point but should also be a selection in the combo box.

    tom

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need Combo Box to Filter Rows

    Clear the combobox to unfilter.


    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  6. #6
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    mehmetcik, I am attaching the file. I probably did something wrong but you can see the results here.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    Hi mehmetcik,

    I really like your solution so I am hoping you can help me to get it working for me. I think it is picking the month earlier than chosen (for example, April when May was chosen). An then the part about the messed up interface after running it a time or two. One other thing. The _activate() for some reason does not populate the combo box when opening the file. I would have thought opening was akin to activate but perhaps not.

    I so hope you can guide me.

    Thanks again,
    tom

  8. #8
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: Need Combo Box to Filter Rows

    Use the Workbook_Open event to load the combo box.

    In Format Control for the combo box set Properties to Don't move or size with cells.
    In properties from the right click menu set ListRows to 13.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    Hey NoSparks...got a question.

    In the code you used the month +1 to get to the right column. It works perfectly, of course. My ACTUAL workbook uses column headers that are not months but labels for various types of documents. How would we modify the code to choose the right column when we need to reference the row of combo box options instead of a calendar month?

    Thanks,
    tom

  10. #10
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    190

    Re: Need Combo Box to Filter Rows

    Make the list exactly what the headers are then this should do
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    10-08-2012
    Location
    San Clemente, California
    MS-Off Ver
    Office365
    Posts
    383

    Re: Need Combo Box to Filter Rows

    Hi NoSparks,

    Your solution is magnificent!!! It works perfectly, of course. Thanks ever so much for the help.

    All the best,
    tom

+ 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] Filter a Combo Box
    By atdemeo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2016, 03:37 PM
  2. Combo box filter
    By Apollo4life in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2014, 06:43 PM
  3. Combo box filter
    By Apollo4life in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2014, 06:39 PM
  4. Filter using combo box
    By sherlock1241 in forum Excel General
    Replies: 3
    Last Post: 02-09-2014, 08:29 AM
  5. Replies: 8
    Last Post: 12-26-2013, 02:23 PM
  6. Filter using Combo Box
    By 301eco in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-13-2012, 10:54 PM
  7. Great Combo Filter/Search form, cant get DATE filter to integrate. HELP
    By fau5tu5 in forum Access Programming / VBA / Macros
    Replies: 4
    Last Post: 05-18-2009, 05:05 PM

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