+ Reply to Thread
Results 1 to 7 of 7

Userform with multiple checkboxes used for autofilter

  1. #1
    Registered User
    Join Date
    10-22-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    15

    Userform with multiple checkboxes used for autofilter

    Hello all,

    in the attached excel file i'm trying to the following (click the "analyse" button on the top right) :
    clicking "genereer" does a first autofilter and generates a list of everything in that selection. With priorities on the left and projects on the right.
    The 5 checkboxes on the left represent the options in column K, the 20 checkboxes on the right respresent the options in column D.

    Now I want to give the user the possibility to show parts of that first selection. So they should be able to mark 1 or more checkboxes on the left and 1 or more checkboxes on the right and then click the "Toon" button and make the autofilter on the 2 columns (K and D) with those variables that were checked.


    The code so far is situated under the form "Analyse".
    Klusjes V2kopie.xlsm
    My main problem is that I don't know how to tell excel if the checkbox is checked, use it to filter, otherwise don't.

    Thanks in advance for all your help !

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Userform with multiple checkboxes used for autofilter

    Try something like this...


    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-19-2014 at 12:41 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-22-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform with multiple checkboxes used for autofilter

    Thanks for the help so far ; I had to adjust a few things because you put the values in the labels in the array where the labels of the projects contain other information too. Giving the following code :

    Please Login or Register  to view this content.
    while testing I noticed that the arrays don't seem to build up as they should. The filter only works for the first added value, not the others in the array So if I check the A and B priority it only filters on A priority and hides the B.

  4. #4
    Registered User
    Join Date
    10-22-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform with multiple checkboxes used for autofilter

    bump for joy

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Userform with multiple checkboxes used for autofilter

    Quote Originally Posted by JorisDDS View Post
    Thanks for the help so far ; I had to adjust a few things because you put the values in the labels in the array where the labels of the projects contain other information too. Giving the following code :

    while testing I noticed that the arrays don't seem to build up as they should. The filter only works for the first added value, not the others in the array So if I check the A and B priority it only filters on A priority and hides the B.
    I thought I had stripped out the other info from the Labels.
    D(j) = Left(.Caption, InStr(.Caption, " (") - 1) 'remove (#) from caption

    Tip: instead of the x variable, you could use j + 7. This is not your problem though.
    D(j) = (Sheets("Tabellen").Cells(j + 7, "S").Value)

    Your example workbook had autofillter only on columns C5:V5. (not column B).
    Your code in AlgemeenOverzicht_Click includes column B in the Autofilter range.
    Private Sub AlgemeenOverzicht_Click()
    ActiveSheet.Range("$B$5:$V$5000").AutoFilter Field:=20, Criteria1:="=true"
    If column B is included, then change this...
    Please Login or Register  to view this content.
    The field number is dependent on the columns you include in the filter range. (Hidden columns are not counted)


    Also: Be aware that filter criteria for the three columns (column D, column K, and you added column 20 = "true") are addative. All three columns have to match one critera in their respective Array. If there is a match in column D, there would also have to be a match in column K for that same row for it to be visible (and column 20 has to also equal True). Your example file doesn't have any values in column 20. As best I can tell that is column AA based on the columns you have hidden.

    You can use this autofilter for column 20 as its' criteria is not an array.
    .AutoFilter Field:=20, Criteria1:="true"

  6. #6
    Registered User
    Join Date
    10-22-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Userform with multiple checkboxes used for autofilter

    Thank you very much for this final help. I didn't know that hidden columns weren't counted ! Everything works superb now !

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Userform with multiple checkboxes used for autofilter

    You're welcome. I din't know about the hidden columns not being counted as well until I tested it.

+ 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] Call different macros using multiple control checkboxes in a userform
    By Sideshow1447 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-04-2013, 04:39 PM
  2. Checkboxes in Userform Creates Multiple Data Entries
    By Daneshav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2013, 09:37 PM
  3. Using multiple checkboxes to autofilter several columns
    By rabert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2013, 05:54 PM
  4. Print Sheets based on checkboxes in UserForm, Checkboxes also control another macro
    By krackaberr in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 03-05-2013, 11:12 AM
  5. Checkboxes and autofilter
    By LeeroyB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2011, 09:15 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