+ Reply to Thread
Results 1 to 13 of 13

How to better search with MATCH function in user form?

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    How to better search with MATCH function in user form?

    Hi. I'm using MATCH in my userform (phonebook): it goes like that: if you type person's full name (accurately!) then you get his/her full details, like his/her phone, email, etc. But what if users don't know the full name of the person they are looking for, say they only know last name, how do I use MATCH then? I guess there is a way to "soften" the search criteria?
    Last edited by GIS2013; 08-29-2013 at 03:09 AM. Reason: typo

  2. #2
    Valued Forum Contributor
    Join Date
    09-04-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    463

    Re: How to better search with MATCH function in user form?

    If you provide the same sample file then i can help you?

    Regards
    CA Mahaveer Somani

  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to better search with MATCH function in user form?

    Hi GIS2013,

    See if the suggestions and / or my code from this thread from just yesterday helps.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    @ Mahaveer, thanks. I'll upload sample soon.
    @ Robert, thanks. I've read your code, and since I'm not (yet) a VBA expert, I'm rather hesitating to change the core of my code, the MATCH method, I saw that you've used FIND rather than MATCH, so any chance we can proceed with MATCH? Maybe I can "fine tuning" the function arguments?

  5. #5
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    The sample is attached. Please ignore any error that causes my search button to return actually blank textboxes2&3. The principle is that one types Jo, for example, and receives: Doe, [email protected] in textboxes2&3 accordingly
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    Hi guys, any further information is required?

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to better search with MATCH function in user form?

    As your file has a xlsx extension, it's macro free. There cannot be any forms on it

  8. #8
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    Yes, sorry for that. Now it's enclosed. So the two entries I've entered represent two problems:

    a) I'd like the user to type jo and get john doe's details (company and email)

    b) What the user would see if the name john is entered? There are two items with the same name..

    ThankYou
    Attached Files Attached Files

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to better search with MATCH function in user form?

    Add a listbox to the userform, set it's ColumnCount to 3 and add this code to the userform module.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  10. #10
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    Splendid Norie Thank you!

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to better search with MATCH function in user form?

    Hi GIS2013,

    Though Norie has provided a great solution, I've attached my following code to the user form on the attached workbook as well which also uses a listbox approach.

    HTH

    Robert

    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: How to better search with MATCH function in user form?

    Hi Robert. It's a great option, though I need one modification. The sample range is tiny A2:B3. But in real life it'd be much larger. So it might be tedious to find somebody called xavier (for the X). So what's the best way to keeping your very tightened code but at the same time replacing the listbox with a textbox?

  13. #13
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to better search with MATCH function in user form?

    Keep the listbox as it has scroll bars for large datasets. If you have the data sorted by name (you could build this in code before the form is opened) it's then no problem to scroll down and easily select (click on) the desired person.

+ 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. Search Function - User Form
    By Disturbedguy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-01-2013, 07:49 AM
  2. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  3. how to use VBA to search and return search result in the user form
    By pearlynie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2013, 07:58 AM
  4. Match new password to specific user and update list via custom user form
    By Sargekd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2011, 09:40 AM
  5. Re: Search Function in a User Form
    By jason_kelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2010, 08:45 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