+ Reply to Thread
Results 1 to 7 of 7

Use Checkbox and Combobox as filter

  1. #1
    Registered User
    Join Date
    08-04-2015
    Location
    Hong Kong
    MS-Off Ver
    2003
    Posts
    3

    Use Checkbox and Combobox as filter

    Hi all,

    I am new to VBA and really got problems that i could not solve. Will be appreciated for you kind help!

    In the attached, the effect I want is to (separate two things)

    1. tick the check box(single or multiple) on the "cover" sheet, and then click the demand button "Basic Information", and then it will lead me to the "basic info" sheet with the column A "Province" filtered.

    2. again tick the check box (single or multiple) on the "cover" sheet as the first criteria (corresponding to the column M: "Headquarter" on "companies" sheet), and then click the demand button "Listed Companies", which will show me the userform to let me choose from the combo boxes, and then click "OK" and it will hopefully lead me to the results on "companies" sheet which are satisfied with the 4 criteria (Provinces ticked in the check box, and other 3 in the userform). I may have some thoughts for a single check box (didn't work that nicely though), but really hv no clue for multiple check boxes.

    I have tried to create the combo box already but failed to deal with the check box as the first-layer filter (or run with the combo box at the same time)

    Sorry to bother but will be more than grateful for your help! Can you kindly give me a hint or give me some examples in the attached so that I can try harder to figure out the rest?

    Thanks...a million...lol. Pls see attached as below.

    Trial start 20150805.xlsm
    Last edited by charleswang; 08-04-2015 at 11:28 PM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Use Checkbox and Combobox as filter

    to make things simpler i went and renamed all your check boxes to the name of the city instead of the default (checkbox 1,2 ....etc)
    this makes coding much easier

    Please Login or Register  to view this content.
    this is the code i got for the filter.
    ps for anyone following ...i may have not optimised the array but it works in its current state...please correct me if i have done it incorrectly

    does this answer your first question?
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    08-04-2015
    Location
    Hong Kong
    MS-Off Ver
    2003
    Posts
    3

    Re: Use Checkbox and Combobox as filter

    Re,

    Thanks a lot, Hum! It works nicely.

    I also modified the codes a little so that it can direct me to the "basic info" sheet after clicking the "basic info" button.

    I basically understood the underlying logic, but may I ask why do I need to check the auto filter? Why would one already exist? I got a bit confused...

    Further, for the second question, I tried to apply similar codes above and reset the array for criteria, but somehow it didn't work...Can you also kindly give me a hint regarding Q2...running the check boxes as filter together with the combo boxes in the userform? i.e., to tick the check box (single or multiple) on the "cover" sheet as the first criteria (corresponding to the column M: "Headquarter" on "companies" sheet), and then to choose from the combo boxes in the userform to get the filtered results. Thanks again!

    Pls see attached as below.
    Cheers!

    Trial start 20150806 v1.xlsm
    Last edited by charleswang; 08-05-2015 at 03:10 AM.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Use Checkbox and Combobox as filter

    Please Login or Register  to view this content.
    i suppose check is probably the wrong word...it should read disable existing autofilter if one exist
    if none exist then nothing happens. it just to make sure that there is no autofilter before applying a filter criteria

    if an autofilter already on worksheet applying another criteria will not overwrite existing one
    so the easiest way to overcome this is just to disable autofilter and start fresh

    ill have a look at Q2 tomorrow

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Use Checkbox and Combobox as filter

    For Q2
    basically use the same code for Q1

    Please Login or Register  to view this content.
    • change the WS to point to worksheet Companies
    • criteria filter field 13 (M)
    • extend autofilter from A:I to A:M

  6. #6
    Registered User
    Join Date
    08-04-2015
    Location
    Hong Kong
    MS-Off Ver
    2003
    Posts
    3

    Re: Use Checkbox and Combobox as filter

    Good day, mate!

    It's of great help! Thanks for every effort!

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Use Checkbox and Combobox as filter

    glad to help

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Add CheckBox To ComboBox
    By BiduraKumar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2016, 02:38 PM
  2. [SOLVED] ComboBox and CheckBox criteria
    By bqheng in forum Word Programming / VBA / Macros
    Replies: 8
    Last Post: 01-16-2015, 02:15 AM
  3. Excel Userform combobox or checkbox?
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2014, 01:58 PM
  4. Replies: 0
    Last Post: 04-07-2014, 12:22 PM
  5. [SOLVED] Filter Combobox base on selection from previous combobox
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2013, 07:25 PM
  6. Disable combobox from checkbox...?
    By hanifYP in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-01-2013, 01:59 AM
  7. using checkbox to change combobox items
    By jdasp49 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-30-2012, 03:40 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