Partial match on search

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question

    Hi,


    I am after some help, I've got a macro for searching multiple worksheets/books and print to Dashboard the results.


    Only problem is it has to be exact matches. I am looking for help to make it look for partial, as several people will have access and not all know the correct names/id's


    Many thanks for any help. I am new to this and got my macro from elsewhere.


    Attached is the file that I got from someone else, just need to adapt it to partial search if possible?

  • Hi and Welcome to the Forum :)


    You could test following instruction

    Code
    1. If dataArray(i, searchField) = "*" & searchValue & "*" Then


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Hello again,


    Could you share a few examples of what you are actually defining as ' partial matches ' ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Regarding your first example ' Part of the name as in Jo for John ' ... using "*" & searchValue & "*" should work ...


    Have you tested this particular example ?


    Regarding your second example ' Part of the ID ' ... this field (cell E4) was not mentioned in your first message ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Regarding your first example ' Part of the name as in Jo for John ' ... using "*" & searchValue & "*" should work ...


    Have you tested this particular example ?


    Regarding your second example ' Part of the ID ' ... this field (cell E4) was not mentioned in your first message ...

    If I put that in, then none of the searches work, even the exact match.


    Sorry I missed out the E4 part.

  • Currently I can search if i know either tthe full code, description or size as i can select which coloumn to search in using E4, but am after a way to search in those coloumns for a partial part of the code, description or size.


    Thanks for your help I know I'm being a bit of a pain.

  • Quite honestly ... without real-life examples .... it is rather difficult to visualize the challenges you are facing ...


    It could very well be that you are confronted with situations more complex than ' regular ' partial matches ...


    If that is the case, you should consider fuzzy logic ... and probably use the following add-in :


    https://www.microsoft.com/en-u…oad/details.aspx?id=15011


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Thanks for your help, found this on Mrexcel forum and it works;


    If InStr(1, dataArray(i, searchField), searchValue, vbTextCompare) > 0 Then


    With a Option Compare Text at the start.


    Thank you again for the help


    :)