+ Reply to Thread
Results 1 to 9 of 9

User Form to Search multiple Criteria to return multiple Results

  1. #1
    Registered User
    Join Date
    03-18-2010
    Location
    Edmonton, AB, Canada
    MS-Off Ver
    Excel 2002
    Posts
    28

    Question User Form to Search multiple Criteria to return multiple Results

    Thank you in advance for your consideration of this question.

    I have a completed data table that users will need to search for results in. I would like to create a user form that will allow them to input criteria (selecting from 1 or more dropboxes) and then return results from a specific column. The trouble is that I would like it to search from multiple columns and rows and find each instance of any of the chosen criteria, and then return each resulting output from a set column in the same row.

    I have attatched a small sample simplified workbook with data to present a clearer picture.

    I am just not that familiar with searching for multiple results. Thanks again for looking at this.
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: User Form to Search multiple Criteria to return multiple Results

    Hi Calleth,

    Find the attached that uses an Advanced filter that is triggered by the event of changing Q2 or Q3. You will need some logic in the VBA to determine the rows to be used in the Advanced Filter.

    Note - the criteria of the Advanced filter on the same row is AND and if different rows is OR.

    see attached.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: User Form to Search multiple Criteria to return multiple Results

    I took a different approach than your post requested. I included a listbox instead of multiple combo boxes. Click on the SHOW FORM button to start. You can select multiple options. The output is on Sheet 2.

    Let me know if it helps.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-18-2010
    Location
    Edmonton, AB, Canada
    MS-Off Ver
    Excel 2002
    Posts
    28

    Re: User Form to Search multiple Criteria to return multiple Results

    Thank you for your efforts. I'm very appreciative!! I see what this is doing and it is interesting. I will explore it to see if I can make use of it.

    The only difference in its execution from our original intentions is that if a user selects "Toys" in Q2 or Q3, it is only searching Category 1 data. We meant for it to search all 3 categories, otherwise users will have to enter "Toys" in all 3 columns to find all the Names for Toys data.
    Last edited by Calieth; 08-15-2011 at 05:32 PM.

  5. #5
    Registered User
    Join Date
    03-18-2010
    Location
    Edmonton, AB, Canada
    MS-Off Ver
    Excel 2002
    Posts
    28

    Re: User Form to Search multiple Criteria to return multiple Results

    Quote Originally Posted by BigBas View Post
    I took a different approach than your post requested. I included a listbox instead of multiple combo boxes. Click on the SHOW FORM button to start. You can select multiple options. The output is on Sheet 2.

    Let me know if it helps.
    Thank you very much for your quick response. I certainly am open to different approaches.

    The only thing I note with this solution is that it is producing a single result. For example when the user selects both "Toys" and "Service" it is going to "Brenda Jones". It should produce a list that shows anyone who has either "Toys" or "Service" in any of the Categories, so 7 differnet names.

    Also, when I run the form more than once it seems to fail to execute. Though we are having network issues and I'm unsure if they may be affecting it.

  6. #6
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: User Form to Search multiple Criteria to return multiple Results

    Hi Calieth,

    I am experience neither of the two problems that you have mentioned. When I use my sample workbook and select both Toys and Service, I actually populate 9 different. The reason for the difference is that I don't capture for duplicates, which we can do once we refine the code in the future. Also, I ran the code multiple times without problems.

    Are you running the code on the sample workbook that I've provided or have you imported the userform into a different workbook? Write back so we can further work on your request.

  7. #7
    Registered User
    Join Date
    03-18-2010
    Location
    Edmonton, AB, Canada
    MS-Off Ver
    Excel 2002
    Posts
    28

    Thumbs up Re: User Form to Search multiple Criteria to return multiple Results

    Quote Originally Posted by BigBas View Post
    Hi Calieth,

    I am experience neither of the two problems that you have mentioned. When I use my sample workbook and select both Toys and Service, I actually populate 9 different. The reason for the difference is that I don't capture for duplicates, which we can do once we refine the code in the future. Also, I ran the code multiple times without problems.

    Are you running the code on the sample workbook that I've provided or have you imported the userform into a different workbook? Write back so we can further work on your request.
    Thank you very much for your reply again. Tried it this morning and it is functioning exactly as you described, clearly our server issues were causing some problems. This will work perfectly I think.

    But yes, the ability to remove duplicates would be very helpful. And also somethign I've never coded for before.


  8. #8
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: User Form to Search multiple Criteria to return multiple Results

    You mentioned that you are new to VBA, so before we work on handling duplicate entries, is there anything else that you need modified in the code or in the way that it returns. Once we are confident that the code runs as needed, we can the add code to prevent duplicate entries.

  9. #9
    Registered User
    Join Date
    03-18-2010
    Location
    Edmonton, AB, Canada
    MS-Off Ver
    Excel 2002
    Posts
    28

    Re: User Form to Search multiple Criteria to return multiple Results

    Little cosmetic things like shutting down the form after and listing the criteria choices the user made is code that I think I can do myself unless there is any special trick with this code that would change how that would normally work.

    Other than that, I think this is good to go.

    Oh, and clearly I gave a simplified version of the worksheet. I will have to add in additional selctions for the user to pick from.
    I assume that I can just modify the code with the additional choices, and that there is no set limit on the number of choices this code can search through?

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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