Display Search Results in a ListBox – Excel VBA




About this tutorial:

Video duration: 25:37
In this video we display search results in a listbox on a userform in Excel VBA.

In this scenario, the user is searching for a product. They enter a keyword and the search results are shown in a listbox. They then make a selection and it is added to the spreadsheet.

Enrol in the online Excel VBA course for beginners –

Read the full tutorial and get access to the file and code here –

During the video we create a dynamic named range using the technique explained in this video – – dynamic named range

*** Online…

Incoming search terms:

Post Author: OfficeTutes.com

Apple lover, ICT and LEAN consultant, MS Office lecturer My other website with video tutorials - Tutorials, guides and news for iPhones and iPads

22 thoughts on “Display Search Results in a ListBox – Excel VBA

    Farhan Islam

    (November 29, 2019 - 2:38 am)

    Plzzz reply This vba code is not running on other computer .but only running in computer where it is made .

    Eivind Steinsbø

    (November 29, 2019 - 2:38 am)

    Thanks Computergaga!
    One Question:
    In this video you can only search matches in column B "Product name".
    How can I make it search in both columns A "ID" and B at the same time?

    Tahj Bomar

    (November 29, 2019 - 2:38 am)

    Is it possible to have the order form accept free form text/data?

    Leandro Barroso

    (November 29, 2019 - 2:38 am)

    Thanx bro!

    Craig Costford

    (November 29, 2019 - 2:38 am)

    This is superb, this has worked really well. I wonder, instead of adding the results of the listbox onto a spreadsheet could you select the search results you want then add them into another userform. For example one of the columns on the listbox results could be date, which when added would go into a userform – textboxdate….. if so, I would love to know how to do that!!

    Gavin Flanigan

    (November 29, 2019 - 2:38 am)

    So if I was doing something similar but copying the data to a userform I would replace row 10 with "Userform2.Textbox1.value = Worksheets("Product Search").cells(listboxrow,1).value" ?

    Joyce Jas

    (November 29, 2019 - 2:38 am)

    where can the vlookup tutorial be found?

    Alpesh Patel

    (November 29, 2019 - 2:38 am)

    Hi. I have tried to replicate this search function (don't require the Add Product cmd). But when I'm doing a search, then another search straight after, the listbox seems to populate with both the old and new search results. Is there anyway to resolve this? Thanks

    Eduard Abasula

    (November 29, 2019 - 2:38 am)

    hi sir i have a question about my project about searching the textbox it is possible to search the last 3 digit number using command button and textbox? thank you

    Pritesh Gala

    (November 29, 2019 - 2:38 am)

    I have made full file like this, now when I am searching some entry multiple items are coming in list box and when I select some entry to add, all that listbox searched entry is displayed in excel sheet, I want only selected entry,,,, what to do

    John Mallouf

    (November 29, 2019 - 2:38 am)

    I have two questions.  Is it possible for it to search two worksheets in the same workbook?  Also, when I get results, sometimes it pulls the results from my last search as well.  Is there a code that will clear out the prior results before searching?

    Aromal U S

    (November 29, 2019 - 2:38 am)

    thanks for your video demonstration.its really great.
    I used the same for my application. but, could you please help me, how i can make this to filter the listbox values to a combo box search value. presently its shows all the values in listbox.

    Simply Doing

    (November 29, 2019 - 2:38 am)

    bakwas ! ittna lamba choda video ! not good method !

    Samra Shahzad

    (November 29, 2019 - 2:38 am)

    hi, i have required vba code in excel who manuplate data in listbox more than 10 columns, can u help plz

    Paulin Alanmanou

    (November 29, 2019 - 2:38 am)

    This a formula that I type in "Refer to" field.
    =offset('Item Search'!$A$2,0,0, counta('Item Search'!$A:$A)-1,5)

    Question:
    When I try to close windows, this error appears:
    ————————————————-
    There's a problem with this formula.
    Not trying to type a formula?
    Whene the first character is an equal (=) or minus (-) sign,
    Excel thinks it's a formula:
    .You type =1+1, cell shows:2
    To get around htis, type an apostrophe (') first.
    .You type '=1+1, cell shows: =1+1

    ———————————————-
    And he selects "$A$2,0,0,"
    It doesn't let me do nothing.
    How can I fix this error?
    Thank you

    emmy onu

    (November 29, 2019 - 2:38 am)

    Thanks, I followed your video from A to Z but I still got the same problem, when I type in ID I will got a message " No product were found that match your search criteria" and when I type in Name of product I will got this text,"Run-time error `380 Could not set the RowSource property, Invalid property value." and when I click "Debug" it will mark lstSearchResults.RowSource = "SearchResults" with yellow background. Pls Help

    emmy onu

    (November 29, 2019 - 2:38 am)

    Run-time error `380“ Could not set the RowSource property. Invalid property value, Help Pls!

    Diego Graciano

    (November 29, 2019 - 2:38 am)

    Hi, need help with a proyect, I did the exact same steps as the video but when I try to run the UserForm and search something I get the Run-time error "380" RowSource property invalid value, the referenced Dynamic range has the exacte same name as the one I coded in VBA, also tried coding the name inside brackets but didn´t worked… hope you can help me fix this issue, greetings.

    Sandeep Kothari

    (November 29, 2019 - 2:38 am)

    Allan, this is a great video!

    Excel On Fire

    (November 29, 2019 - 2:38 am)

    Louisiana Fiery Pepper Sauce. Well, ok!!! 🔥🔥🔥
    Good work on this project!

    Syed Muzammil Mahasan Shahi

    (November 29, 2019 - 2:38 am)

    Thanks for sharing thin interesting video.

    Willem Mulder

    (November 29, 2019 - 2:38 am)

    Hi Alan, great tutorial!

    I have a question about the InStr function you used.
    Is there a difference between the InStr function and Like. I think the result is the same.

    Kind regards
    Willem

Leave a Reply

Your email address will not be published. Required fields are marked *