+ Reply to Thread
Results 1 to 9 of 9

Filtering list with userform checkboxes

  1. #1
    Registered User
    Join Date
    01-20-2020
    Location
    Houston, Texas
    MS-Off Ver
    2016
    Posts
    6

    Talking Filtering list with userform checkboxes

    I am currently trying to create a userform that will help to filter my list (link) based on what fruits are talked about in which documents. [Click here to see the list] [2]

    For example, looking at my userform below, I would like to be able to click on apples and then click ' Find Documents' in order to filter the excel list to only the documents that talk about apples (543, 45, 723, 44, 86, 95, 7, 33, 64).

    The only way I could figure out how to do was to manually add other columns (D and E), and add 1's / 0's depending on whether or not the fruit were talked about in the document.

    I have then created a macro to filter only the documents containing apples based on the 1's and 0's from column D:

    Please Login or Register  to view this content.
    Then, within the code for the userform,

    Please Login or Register  to view this content.
    I created another macro when clicking on the 'Find Documents' button, to call this Filter Apples function if this is true. If it is checked, then the macro works and it sorts by which documents talk about apples.

    The problem is I do not know where to go from here (if I want to sort by multiple or even just a different item). I figured there was also probably an easier way to do this as opposed to my method so I figured I would reach out for help. Thanks in advance.
    Attached Files Attached Files
    Last edited by will12321; 01-30-2020 at 12:54 PM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Filtering list with userform checkboxes

    Maybe this too much but it works give it a spin.

    I used some coding tricks I was trying out on another project
    Attached Files Attached Files
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    01-20-2020
    Location
    Houston, Texas
    MS-Off Ver
    2016
    Posts
    6

    Re: Filtering list with userform checkboxes

    Thank you so much for getting back to me! That does help, the only issue I am seeing now is that when you filter, it is only filtering for the ones containing just that fruit (when you click apples, only the ones with just apples are filtered). When I click on apples to be filtered, I would like everything to be included that contains apples (even if bananas or grapes are mentioned in the document too). I assume that is from this line here:

    Please Login or Register  to view this content.
    Which to me seems to be saying that if the box is checked, then we are filtering for that exact value.

    Is there any way to say to filter if the column 'contains the word apples' instead of 'equals the word apples'?

    Sorry, I do not have very much experience coding. I really appreciate your help.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Filtering list with userform checkboxes

    My mistake , corrected it
    Attached Files Attached Files

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Filtering list with userform checkboxes

    I use the checkbox's tag as check I modified the check also so that either upper or lower case is checked correctly
    Attached Files Attached Files

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Filtering list with userform checkboxes

    Just for fun an additional checkbox to enter any text (max 20 characters) to search for
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-20-2020
    Location
    Houston, Texas
    MS-Off Ver
    2016
    Posts
    6

    Re: Filtering list with userform checkboxes

    Haha thank you so much. I am still having one issue. I tried to transfer code over to another sheet I am working on. I did not want to post it because it was too much information / sensitive. For some reason, when trying to filter, each row is ending up with a 1 in the filter column if there is text in it, regardless of whether or not it contains the fruit value or not. It does not matter which fruit filter you press, they all do the same thing. If there is not text in it however, then it returns as a zero. Do you know why that would be the case? Everything is basically the same, there are just a couple of extra filter items. Here is the code:

    Please Login or Register  to view this content.
    All I did was adjust the X, adjust the name of the worksheet, as I added a couple of more filtering items. The location of the columns are the same (I want it to search through column C, and the filter column is column E). I have been messing around with it all morning and can't seem to figure it out.

  8. #8
    Registered User
    Join Date
    01-20-2020
    Location
    Houston, Texas
    MS-Off Ver
    2016
    Posts
    6

    Re: Filtering list with userform checkboxes

    Nevermind I figured it out! I did not have the 'Tag' section of the checkboxes filled out. Thanks so much for all the help! Don't know what I would've done if you didn't respond!

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Filtering list with userform checkboxes

    Glad to have been of help. VBA is nothing more than a line by line code execution. it's like reading or telling a story. if this then that else ....
    All you have to do is respect the code syntax, the only limitation is your own imagination and two very important ingredients are time and patience.

+ 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] Toggle between userform checkboxes for multiple pairs of checkboxes
    By L plates in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-25-2016, 06:31 AM
  2. [SOLVED] Filtering through multiple checkboxes VBA
    By Ashley.Martin100208 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-12-2015, 03:52 PM
  3. Checkboxes for Filtering have disappeared :(
    By JM17 in forum Excel General
    Replies: 9
    Last Post: 11-27-2013, 11:17 AM
  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. Filtering to multiple criteria via checkboxes in VBA
    By Viv_bot in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2012, 04:41 AM
  6. List names of selected checkboxes in UserForm as string
    By rockyourteeth in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-27-2012, 07:04 PM
  7. Problems filtering data containing checkboxes???
    By nameyers in forum Excel General
    Replies: 1
    Last Post: 10-18-2007, 02:48 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