+ Reply to Thread
Results 1 to 10 of 10

Excel Userform Searching Multiple Criteria

  1. #1
    Registered User
    Join Date
    04-23-2019
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Professional 2013
    Posts
    5

    Question Excel Userform Searching Multiple Criteria

    This is either the easiest problem to solve, or the hardest, as I've spent hours trying to look this up.

    I have a worksheet populated with about 15,000 rows and 8 columns full of data. I have created a simple userform to quickly search the list, however, I need the ability to search two fields at the same time. I want to find the row with a specific Vendor Code and Document Type. There should only be one result if both criteria are searched simultaneously.

    Capture.PNG

    My current code for the Find Data button is below. As you can see, I'm only searching for the Vendor Code.

    Please Login or Register  to view this content.
    If anyone could help me that would be amazing. Thank you.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    See in the VBA inner help the sample of the Range.Find method as you can use for the first field.
    Once the field found, check the second field on the same row …

  3. #3
    Registered User
    Join Date
    04-23-2019
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Professional 2013
    Posts
    5

    Re: Excel Userform Searching Multiple Criteria

    Thanks for your reply Marc. Assume I have a limited knowledge of VBA. What would the code look like for what you're talking about? I looked at different Range methods and nothing looked like what I need.

  4. #4
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Excel Userform Searching Multiple Criteria

    Does this help you?
    Data that does not match the search criteria disappears from the list.
    See attached.
    Attached Files Attached Files
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Quote Originally Posted by Typographics View Post
    What would the code look like for what you're talking about?
    It exactly looks like the Range.Find sample in the VBA help !

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Excel Userform Searching Multiple Criteria

    Does this approach fit your needs.
    The comboboxes only load with unique(not repeated) items actually from your database.
    Paste your data into the sheet (it should automatically accommodate expansion).
    Upto 200,000 rows the search is virtually instant.
    torachan.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-23-2019
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Professional 2013
    Posts
    5

    Re: Excel Userform Searching Multiple Criteria

    dotchiejack,

    Thank you so much for helping me. The search function doesn't work for what I need. When I search a Vendor Code and Document type, I only want the rows where those two match. Right now, it gives me everything with a Vendor Code of "X" and Document Type of "Y". In the example below, the highlighted entries are the only ones I want displayed when I search for both variables:

    Attachment 628012

    Everything else works perfectly!

  8. #8
    Registered User
    Join Date
    04-23-2019
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Professional 2013
    Posts
    5

    Re: Excel Userform Searching Multiple Criteria

    torachan,

    Thank you so much for looking at this! I can't have the search criteria be a list, because there are thousands of unique identifiers, so the list would be enormous. It needs to be something I can type in.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: Excel Userform Searching Multiple Criteria

    As if by magic.
    Changed Combo's to TextBoxes and small adjustments to code.
    Try this.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    04-23-2019
    Location
    Tulsa, Oklahoma
    MS-Off Ver
    Professional 2013
    Posts
    5

    Red face Re: Excel Userform Searching Multiple Criteria

    torachan,

    Thanks for the edit! Sorry, yesterday was busy at work. I just wanted to thank you again.

+ 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] Return single value by searching multiple criteria in multiple column
    By Ramesh h&m in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-01-2017, 07:02 AM
  2. Replies: 8
    Last Post: 06-17-2017, 03:28 AM
  3. excel 2003 userform listbox to autofilter. Multiple criteria (beyond two)
    By vbapadawan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2015, 01:36 PM
  4. Searching Data for multiple criteria
    By Mackay2m in forum Excel General
    Replies: 5
    Last Post: 06-04-2015, 11:52 AM
  5. Searching Multiple Criteria in a Column with multiple data
    By cmmercer in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2014, 08:16 AM
  6. Replies: 1
    Last Post: 04-25-2012, 04:30 PM
  7. Searching for multiple criteria in array
    By Puzzel in forum Excel General
    Replies: 11
    Last Post: 11-01-2009, 04:47 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