Display Search Results in a ListBox - Excel VBA

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • 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 - bit.ly/2JvnnRv
    Download the file and code here - www.computerga...
    During the video, we create a dynamic named range using the technique explained in this video - • Create a Dynamic Range... - dynamic named range
    ** Online Excel Courses **
    Excel VBA for Beginners ► bit.ly/2JvnnRv
    Advanced Excel Tricks ► bit.ly/3CGCm3M
    Excel Formulas Made Easy ► bit.ly/2t3netw
    The Ultimate Excel Course - Learn Everything ► bit.ly/Ultimat...
    Creating Sports League Tables and Tournaments in Excel ► bit.ly/2viGg3J
    Find more great free tutorials at;
    www.computerga...
    Connect with us!
    LinkedIn ► / 18737946
    Instagram ► / computergaga1
    Twitter ► / computergaga1

ความคิดเห็น • 104

  • @arsalanahmed5706
    @arsalanahmed5706 3 หลายเดือนก่อน

    nobody made such a search system in excel which is so effective like this one

  • @saidkurt3735
    @saidkurt3735 2 ปีที่แล้ว

    Merhaba vermiş olduğunuz bilgiler için çok teşekkür ederim

  • @sushilpugalia2831
    @sushilpugalia2831 2 ปีที่แล้ว

    Thanks Computergaga!
    It helped me a lot. I am new to customise excel workbook via VBA. It is easy to make many changes in code to suit my requirements as I know VB coding. Your logic to copy search results to new range, did the trick. I was attempting autofilter which was not giving me visual output I needed.
    Once again I thank you.

    • @Computergaga
      @Computergaga  2 ปีที่แล้ว

      You're welcome, Sushil. Thank you.

  • @Sage-Thyme
    @Sage-Thyme 3 ปีที่แล้ว

    Excellent vid, just the right level of info and I was so pleased when you capitalised the 'p' because it was bugging me also.

    • @Computergaga
      @Computergaga  3 ปีที่แล้ว

      Great to hear! Thank you 👍

    • @Sage-Thyme
      @Sage-Thyme 3 ปีที่แล้ว

      @@Computergaga I'm rather new to VBA, and very much self taught (with a fair amount of Googling), currently trying to create a stock control system for laboratory traceability purposes and the first half of your video showed me just how to create a search function to go backwards from a stock lot number to the specimen number, and you've made it so simple even a novice like myself can follow, I really appreciate that even though you said you were keeping it short you took the time to show what related to what and were data was being pulled from. I've just subscribed because I have no doubt I'll find more useful info on your channel and I want to be able to find it easily. Thanks so much for taking the time to make these.

  • @YT2007XYZ
    @YT2007XYZ 2 ปีที่แล้ว

    Great Video.... this works great. Is there a way to select multiple products (ie. if you searched on Louisiana and it returned a list of 8 products containing Louisiana), how could I select 2 or more of the products without having to do a second or third search? Example: I'm searching on a golf course that has multiple tees (Men's Black, Blue, White, Red, and Ladies White and Red tees), and I wanted to return the details of Men's White and the Ladies Red tees. Is there a suggested way to pull both desired tees without having to go through the process of describing a second search?

  • @BillyLynn-e1t
    @BillyLynn-e1t ปีที่แล้ว

    Very useful. Thank you. What do I need to do if I want same search user form, with same stock data and same product search, but for two form sheets, lets say sheet "form" and sheet "form1"?

  • @thetproject2266
    @thetproject2266 2 ปีที่แล้ว

    Thanks for the video very useful
    If I could ask you , how did you use the vlookup function in the first minute of the video how do you type in the cell and you take the row from the other sheed.. Do you have a video about this ?

  • @haroldfinch6379
    @haroldfinch6379 3 ปีที่แล้ว

    Thanks..... I have been looking for this type of solution for two days.....
    I implemented this inside a userform and all populated a google search like suggestions in combobox drop down....😀😀

    • @Computergaga
      @Computergaga  3 ปีที่แล้ว

      Excellent! Happy to help, Harold.

  • @kennethfrandsen7187
    @kennethfrandsen7187 2 ปีที่แล้ว

    Great how-to! Thanks! I need a little help though. If I want to use this on another sheet and DON'T want the Worksheets("Stock Data").Activate to actually show, but stay in the sheet I work on. Then how do I do that? The cmdSearch_Click() should just run in the background.

  • @karen1946-o4b
    @karen1946-o4b 2 ปีที่แล้ว

    Hi! thank you very much for this tutorial. What will be the instr code for a search on multiple columns and not just one?

  • @OzduSoleilDATA
    @OzduSoleilDATA 6 ปีที่แล้ว +4

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

  • @eivindsteinsb726
    @eivindsteinsb726 5 ปีที่แล้ว +3

    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?

    • @sushilpugalia2831
      @sushilpugalia2831 2 ปีที่แล้ว

      Please make necessary changes in If condition to search in as many columns.
      If InStr(1, .Cells(RowNum, 4).Value, tbSearchText.Value, vbTextCompare) > 0 Or _
      InStr(1, .Cells(RowNum, 5).Value, tbSearchText.Value, vbTextCompare) > 0 Or _
      InStr(1, .Cells(RowNum, 6).Value, tbSearchText.Value, vbTextCompare) > 0 Then
      This code is from my project which I changed to suit basic requirement and you are asking for same.

    • @Grundlestix
      @Grundlestix 2 ปีที่แล้ว

      @@sushilpugalia2831 This is similar to what I was looking for in a comment I posted above. The Or_ creates a compile error though so I'm not sure how this is working for you

  • @ulquiorra3504
    @ulquiorra3504 3 ปีที่แล้ว

    Thanks for this video.
    I kindly need help here, if there are 3 worksheets available, how do you then search through these worksheets and display the result in the list-box?

  • @flavours1018
    @flavours1018 3 ปีที่แล้ว

    sir do you have a simple inventory related to this video?

  • @MrTopdawg47
    @MrTopdawg47 2 ปีที่แล้ว

    Curious, can you use any wild card search’s in the text search box?

  • @sandeepkothari5000
    @sandeepkothari5000 6 ปีที่แล้ว +2

    Allan, this is a great video!

  • @pembelajarexcel4116
    @pembelajarexcel4116 4 ปีที่แล้ว

    Thank u for this very useful tutorial...

    • @Computergaga
      @Computergaga  4 ปีที่แล้ว

      You're welcome. Thank you Pembelajar.

  • @craigcostford8785
    @craigcostford8785 5 ปีที่แล้ว

    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!!

  • @SyedMuzammilMahasanShahi
    @SyedMuzammilMahasanShahi 6 ปีที่แล้ว +3

    Thanks for sharing thin interesting video.

  • @ahmadal-afiq9659
    @ahmadal-afiq9659 3 ปีที่แล้ว

    hi i tried using this code for my project, so mainly i used your codes and i changed the name of the sheets to suit my project. my problem is on the product search sheet is where the search results is going to appear, so if i search something multiple results will show based on the keyword, instead of populating one row at a time, my product search sheet populates all the search results, i mean all the suggestion that appears in the list box, goes into the product search sheet, do guide me on how to fix this, thank you so much.

  • @uo7immunologiamolecolare971
    @uo7immunologiamolecolare971 3 ปีที่แล้ว

    This doesn't work on mac, because row source is not supported, so nothing comes back in the listbox. Any suggestion or change to the listbox code so that it can work even on mac? This is perfect for my needs, but unfortunatly works perfectly only on windows computer. Thanks for the help

  • @grishkamm
    @grishkamm 4 ปีที่แล้ว

    Hi. Thanks for the video! Helped me fixing script a lot :) Question: If in data inventory list there is a empty cells exist, how to make it continue scanning rows without stopping?

    • @IulianRaduta
      @IulianRaduta 4 ปีที่แล้ว

      Hi , every product has an Id , counta function count only cells with something in there .You could use Range("A2").CurrentRegion.Rows to count rows involved in range you need to.

  • @rajeshpks
    @rajeshpks 4 ปีที่แล้ว

    Thanks a lot! this is very useful video..

  • @joyzuniga3963
    @joyzuniga3963 4 ปีที่แล้ว

    Thanks for the code, it seems the video, your example was 2 or 3 data can load fast on listbox, as I tried this, I am trying to load multiple rows of data like above 100 rows, I encounter Not Responding first on Excel, although it is back in a while like 15sec. Is there a way for this, to load hundreds of column based on criteria?

    • @ConsulthinkProgrammer
      @ConsulthinkProgrammer 4 ปีที่แล้ว

      Try this for an alternative in google sheets
      th-cam.com/video/XOzRCwyCkdA/w-d-xo.html

  • @arcaetambis5483
    @arcaetambis5483 3 ปีที่แล้ว

    Thanks for this amazing video. Although I encountered a problem if there are no results when searching. The message box pops up which is its purpose but then since there is no list to display, I get an Error code 380. "Could not set the RowSource property. Invalid property value." Pls help.

    • @sergiocordoba1792
      @sergiocordoba1792 3 ปีที่แล้ว

      This might be a solution, you can assign the property like: Listbox1.RowSource = Empty inside that If statement and the list will be just blank. I know it might be late but i hope this helps someone

  • @gavinflanigan709
    @gavinflanigan709 5 ปีที่แล้ว

    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" ?

  • @aromalus451
    @aromalus451 6 ปีที่แล้ว

    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.

    • @disposable_hero1725
      @disposable_hero1725 5 ปีที่แล้ว

      I did mine to use a drop down list instead of search box, set up a drop list as normal then name it txtKeywords in its properties then it will work to the code in this video, txtKeywords in the code is reference to the text search to be done.

  • @genterprisesskn5319
    @genterprisesskn5319 4 ปีที่แล้ว

    Hi Computergaga. In this video, you mentioned about worksheet construct, but you didn't show example because it was only three (3) columns. I have a work sheet with over 50 columns, therefore i would like you to please send me the "construct" method, so that i don't have to type so many data for my many columns worksheet. Thank you in advance.

  • @bogztv6219
    @bogztv6219 5 ปีที่แล้ว

    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

  • @willemmulder7304
    @willemmulder7304 6 ปีที่แล้ว

    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

    • @Computergaga
      @Computergaga  6 ปีที่แล้ว

      Yes, the Like operator will work just aswell. They are very similar. You can use wildcard characters with Like. And with Instr you can specify whether to match case or not.

  • @S.art1396
    @S.art1396 4 ปีที่แล้ว

    Sir, kindly explain and make a video about 'Error in loading DLL' in Microsoft Visual Basic.

  • @silasvankweka5785
    @silasvankweka5785 4 ปีที่แล้ว

    Thanks for the good sequence on how create data entry with search function
    But I need to know what is difference between AddData and Update Cimmandbutton

    • @IulianRaduta
      @IulianRaduta 4 ปีที่แล้ว

      Difference is: when you Add something , you put some data in area , when you update you modify an existing data in that range.

  • @oubadouba
    @oubadouba 4 ปีที่แล้ว

    thank you soooooo much I'm officially subscribed !!!!!

    • @Computergaga
      @Computergaga  4 ปีที่แล้ว

      Excellent! Happy to help Zineb.

  • @Dezadna
    @Dezadna 4 ปีที่แล้ว

    thank you for this video it's what i was hoping to find , i tried it but somehow it show me this code If InStr(1, Cells(RowNum, 2).Value, txtkeywords.Value) > 0 Then
    highlighted in yellow ? what is the problem plz ( ps i tried everything like in the video )

    • @gul531
      @gul531 3 ปีที่แล้ว

      txtkeywords

  • @titi7776
    @titi7776 4 ปีที่แล้ว

    Thank you for this vidéo. it would have been a "cooler" version if the user doesn't have to click on a search button . A google-search like search bar with results showing in the the listbox.

  • @alializadeh8195
    @alializadeh8195 ปีที่แล้ว

    مرسی

  • @eugenesonmiranda6830
    @eugenesonmiranda6830 4 ปีที่แล้ว

    I did this and it works! but unfortunately it does not show specific data, what I mean is there are other data in the list box. how can I fix it?

  • @eduardoescutia4970
    @eduardoescutia4970 4 ปีที่แล้ว

    Hello, I've got a question what about having a list but the search criteria could be any of the column, lets say column 1 is part number, column 2 is common code, column 3 is description, how can I create such offset with that in mind, thank you.

    • @shielaquimbo1355
      @shielaquimbo1355 4 ปีที่แล้ว

      you can use AND operator in searching for keyword. Starts in 14:51 in the video. You have to change this part (rownum,2) and the txtkeywords.value.

    • @abliana2455
      @abliana2455 3 ปีที่แล้ว

      @@shielaquimbo1355 where exactly will the AND function go....

  • @MrTopdawg47
    @MrTopdawg47 5 ปีที่แล้ว

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

  • @Grundlestix
    @Grundlestix 2 ปีที่แล้ว

    Is there a way to make this search for the text in more than one column ?

    • @Computergaga
      @Computergaga  2 ปีที่แล้ว

      Sure. I don't see why not.

    • @Grundlestix
      @Grundlestix 2 ปีที่แล้ว

      @@Computergaga What changes would need to be made to the VBA. As it is the column number is static and I havent been able to figure out how to make it search all rows & columns

  • @samrashahzad1541
    @samrashahzad1541 6 ปีที่แล้ว

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

  • @kanbalan3043
    @kanbalan3043 4 ปีที่แล้ว

    I wonder you could solve this problem for me . here we are ... I created a data entry form and linked the database below so that user can select a particular row and then edit or delete so far so good The issue is I want to make this list to be in descending order and as and when a new row of data is entered this appear right at the top so that the user know what is the last piece of data entered

  • @MartinVaupell
    @MartinVaupell 4 ปีที่แล้ว

    Good video..

  • @proyecto2148
    @proyecto2148 3 ปีที่แล้ว

    Is there a code to filter data in a listbox from a textbox with more than 1 million rows?

  • @farhanislam3707
    @farhanislam3707 5 ปีที่แล้ว

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

    • @MrTopdawg47
      @MrTopdawg47 4 ปีที่แล้ว

      Are your macros enabled on other computer?

  • @kanbalan3043
    @kanbalan3043 4 ปีที่แล้ว

    HI IS THERE ANYWAY WE COULD DISPLAY ALWAYS, ONLY LAST ROW OF DATA ENTERED TO APPEAR IN THE FORM

  • @alpeshpatel837
    @alpeshpatel837 5 ปีที่แล้ว

    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

    • @michalfrankowski5328
      @michalfrankowski5328 5 ปีที่แล้ว

      Worksheets("SearchCus").Range("A2:I100").ClearContents

  • @mirasheikh6245
    @mirasheikh6245 3 ปีที่แล้ว

    I got the debug on "if Instr(1,Cells(Rownum, 2) and so on. Why??

  • @jsonkjano
    @jsonkjano 4 ปีที่แล้ว

    how to clear the listbox as well as the product search range/tab you created?

    • @Dan_De_Man
      @Dan_De_Man 3 ปีที่แล้ว

      Either add the code you have in initialisation
      Worksheets("product search").range("A2:c2").clearcontents
      Or just
      Me.lstsearchresults.listindex = -1
      Enter these before you run the do until loop

  • @Hackerciano
    @Hackerciano 6 ปีที่แล้ว

    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.

    • @sybersepp
      @sybersepp 5 ปีที่แล้ว

      Hi Diego Graciano,
      if you still Need a solution for this Problem, try to Change the SearchResults to your Workfolder and not a single worksheet, then it´ll work.

    • @jakubnemcovsky6638
      @jakubnemcovsky6638 5 ปีที่แล้ว

      @@sybersepp What do you mean by that? not sure I understand thanks

  • @priteshgala2414
    @priteshgala2414 5 ปีที่แล้ว

    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

    • @Computergaga
      @Computergaga  5 ปีที่แล้ว

      The technique I use is the one covered in the video. I would like to help more, but I have a demonstration there.

  • @leandro.barroso
    @leandro.barroso 5 ปีที่แล้ว

    Thanx bro!

  • @emmyonu712
    @emmyonu712 6 ปีที่แล้ว

    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

    • @Computergaga
      @Computergaga  6 ปีที่แล้ว

      It is hard to know the root of the problem exactly Emmy, but it certainly is not happy with the search results. Either they are not working correctly to build up the named range. Or it could be a mis-type in the named range.
      The yellow highlight is Excel indicating the problem occurs at that statement. There could be a few reasons why it cannot assign SearchResults to the RowSource though.

    • @sybersepp
      @sybersepp 5 ปีที่แล้ว

      Hi emmy onu,
      if you still Need a solution for this Problem, try to Change SearchResults to your Workfolder and not a single worksheet, then it´ll work. you have to Change it in Name-Manager

  • @joycejas2134
    @joycejas2134 5 ปีที่แล้ว

    where can the vlookup tutorial be found?

    • @LyonWarlock
      @LyonWarlock 5 ปีที่แล้ว

      support.office.com/en-us/article/video-vlookup-when-and-how-to-use-it-9a86157a-5542-4148-a536-724823014785

  • @NinhTran09
    @NinhTran09 3 ปีที่แล้ว

    💯💯

  • @emmyonu712
    @emmyonu712 6 ปีที่แล้ว

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

    • @Computergaga
      @Computergaga  6 ปีที่แล้ว

      Check the named range is assigned to the rowsource like in the video. Wrapped inside double quotations and spelt correctly.
      If not this, have a look at the named range itself. Is the formula in there accurate. Is that named correctly and not mis-typed.

  • @NinhTran09
    @NinhTran09 3 ปีที่แล้ว

    ⭐️⭐️

  • @paulinalanmanou4320
    @paulinalanmanou4320 6 ปีที่แล้ว

    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

    • @paulinalanmanou4320
      @paulinalanmanou4320 6 ปีที่แล้ว

      I result a problem with this link
      answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_winother-mso_2016/error-display-window-theres-a-problem-with-this/fd41b58f-de65-44a4-a086-cc829101c214
      so I change (,) with (;)
      And I have =offset('Item Search'!$A$2;0;0; counta('Item Search'!$A:$A)-1;5)
      it works fine!

    • @Computergaga
      @Computergaga  6 ปีที่แล้ว +1

      Good work Paulin. Yes the error they show i not helpful. The semi colon ; is used by Excel user in mainland Europe primarily.

  • @niltaxi6401
    @niltaxi6401 3 ปีที่แล้ว

    Show!! +1