+ Reply to Thread
Results 1 to 6 of 6

Multiple Country filter (>2 criterias) with activeX checkboxs

  1. #1
    Registered User
    Join Date
    01-15-2016
    Location
    Luanda
    MS-Off Ver
    Windows 2013
    Posts
    6

    Multiple Country filter (>2 criterias) with activeX checkboxs

    Hi there,

    I have searched for a looooong time in here for help and it got me to this point... But now it feels like a serious challenge! Please, could you help me on filtering based on checkboxes?

    The thing here is that every cell has several country shortname (eg: EU IT PT FR ES UK BE NL LU CH PL CZ AT) so I would need the filter to search for *EU* if the user clicks the Checkbox EU + *UK*, etc...

    My current code is based on this thread (File: Book2 v2.1.xlsm‎) https://www.excelforum.com/excel-pro...heckboxes.html

    Please Login or Register  to view this content.
    The original code wasn't working properly with the *(Country)* so I ended up putting in the Checkbox caption the asteriks (eg: *PT*, *ES*, *UK*).

    What do you think?!
    Thanks in advance
    Last edited by GustavoPT; 11-23-2017 at 01:46 PM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Multiple Country filter (>2 criterias) with activeX checkboxs

    With Autofiler, you can only use up to 2 value with wildcard. Any more, and you can't use wildcard filter.

    Alternate approach is to use Advanced Filter (xlFilterInPlace).

    Though this approach will require you to set up criteria range (either in another sheet or some out of way range).


    Or you can just hide rows that doesn't meet the condition (Rows().EntireRow.Hidden).

    Upload sample file that replicate your set up, and I can help code it.

    Yet, another approach is to create array of wildcard match values, and use that for filter criteria.

    Edit: To clarify last point, you'd first find all matches to "*EU*" etc and then build your array of matching strings.
    Last edited by CK76; 11-23-2017 at 04:52 PM.
    ?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
    Registered User
    Join Date
    01-15-2016
    Location
    Luanda
    MS-Off Ver
    Windows 2013
    Posts
    6

    Re: Multiple Country filter (>2 criterias) with activeX checkboxs

    Thanks for your reply CK76!

    The hide rows method I think would work well, as long as the table still have filtering on (for easier user use).

    Here's my sample file.

    Many thanks!

    https://www.excelforum.com/attachmen...1&d=1511515467
    Attached Files Attached Files
    Last edited by GustavoPT; 11-24-2017 at 06:02 AM.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Multiple Country filter (>2 criterias) with activeX checkboxs

    So, how should filter behave exactly when multiple check boxes are ticked?

    Should it show all rows that are match to any? Or should it have match for all ticked check boxes?

    Here's quick sample for the first type (show row that contain any). I went with method to create list of unique and using auto filter. Since, that had least impact on existing code.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-15-2016
    Location
    Luanda
    MS-Off Ver
    Windows 2013
    Posts
    6

    Re: Multiple Country filter (>2 criterias) with activeX checkboxs

    CK76, It's exactly that what I needed! Eg: I can then create an extraction of items in country PT, ES and IT.

    And just for curiosity, if the desired outcome was the filter to find items with all checked countries, which method would you recommend since the list is already created? (Hope this questions makes sense)

    Many sincere thanks!!
    Last edited by GustavoPT; 11-24-2017 at 10:55 AM.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Multiple Country filter (>2 criterias) with activeX checkboxs

    You mean data filtered for rows that match all the checkbox (AND operator)?

    I'd probably use the same method, just add another layer before adding items to dictionary object. I.E. Loop through each cBox item and +1 to some variable to serve as counter. When counter = UBound(cBox) then add to dictionary, else skip.

    Edit: Oh and would add dictionary.count check. When 0 show msgbox saying there are no item that meet all criteria and remove filter.
    Last edited by CK76; 11-24-2017 at 11:17 AM. Reason: See Edit:

+ 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 pivottable with multiple criterias
    By Petter120 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 09-29-2017, 06:34 AM
  2. [SOLVED] Multiple ActiveX Checkboxs
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2017, 04:51 PM
  3. Advanced Filter with Multiple Criterias
    By etaver87 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2016, 12:24 PM
  4. [SOLVED] values in ActiveX combo boxes dependent on multiple criterias
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2016, 11:18 AM
  5. VBA to Hide/show columns based on a filter and multiple criterias
    By Daniel B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2014, 05:07 AM
  6. Replies: 0
    Last Post: 02-02-2014, 08:42 AM
  7. [SOLVED] CheckBoxs to print multiple pages
    By nighttrainrex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2012, 08:32 PM

Tags for this Thread

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