VBA - User Form: Search as you Type using TextBox and ListBox | Search by criteria

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • In this video, we will see how to display the search result in a list box on Userform Excel VBA.
    Feeding a Listbox.
    Filter a Listbox using multi-criteria with Combobox and Textbox.
    Perform intuitive searches.

КОМЕНТАРІ • 60

  • @malcolmt3125
    @malcolmt3125 7 місяців тому +2

    This is absolutely awesome, there are very few that implement a userform for this type of search, that you can actually follow along and can tweak to get it into your own project. Thank you for you time in putting this out for the masses. Not sure why you didn't post the actual code as well, but that made for a better understanding

  • @Jojosmith342
    @Jojosmith342 Рік тому +1

    Excellent. You're great VBA teacher. Thanks for your best code and another useful tutorial. Your code works like miracle. All thumbs up. Already subscribed

  • @JoshuaCatle
    @JoshuaCatle 8 днів тому

    Nice! This is a huge help. Thank You!

    • @hay_kel
      @hay_kel  7 днів тому

      Thank you for your comment

  • @xoxo6911
    @xoxo6911 5 місяців тому +3

    How do you display more than 10 columns in the list box? Only able to show 9

  • @Belive_in_Jezus_Christ
    @Belive_in_Jezus_Christ 5 місяців тому +4

    You didn't show how the header of each of the 9 columns is placed at the end of the video, we were left with the form without the header of the columns?

  • @shilpag8172
    @shilpag8172 4 місяці тому

    Hello, can we have something similar when the user form is connected to a MS Access with a set of data..is there any video on this?

  • @cyberbeast1789
    @cyberbeast1789 3 місяці тому

    with this code is it possible than when you double click the listbox data will display on texboxes?

  • @roronoazoro8343
    @roronoazoro8343 Рік тому +2

    good but could have been better and faster to work with the large table by using filtering the table using Wildcard(*) and coping the data to a temp sheet and then bringing the data in the list box with range. by converting the data in to the table it gives whole lot of functions to use for us and still keeping all the sheet functions also.

  • @onlineservices6150
    @onlineservices6150 Рік тому +2

    Sir I need help 🙏
    Why this search method is working slow when data is more than 100 and searh textbox responding very slow. Please give the solution .

    • @angelou8633
      @angelou8633 6 місяців тому

      yeah , it loads very slow. did you find a solution?

  • @abhilashsnamboothiri8134
    @abhilashsnamboothiri8134 Рік тому +3

    sir, it shows an error - variable a is not defined. How can I solve this

    • @shana0165
      @shana0165 Рік тому

      same

    • @edthbkk1
      @edthbkk1 10 місяців тому

      Add "Dim a" to the top of the form, first line

  • @jdresurreccion3304
    @jdresurreccion3304 9 місяців тому

    loved this! I'll test this on the project I am currently working on. Is it possible to conduct the search anywhere in the criteria?
    For example, if I type or, it will show the result of any word that has letters "or" and not just the one that starts with or?

  • @VuongBui-b2k
    @VuongBui-b2k 5 місяців тому

    Is the Excel file used in the demonstration available for download? I did not see the link.

  • @PopoyTanke
    @PopoyTanke 7 місяців тому

    Hi, I'm getting the error variable not defined on a = Len(Me.TxtSearch.Text) where can I set the A variable?

  • @adeshraka6668
    @adeshraka6668 Рік тому +3

    How to search listbox name midlename last name.. Example.. In textbox type..A B C.. result..Adi Bike Care in vba please vba code..

  • @portregaleri
    @portregaleri 9 місяців тому

    I tried to correct the codes for the listview. But I couldn't. Can you edit the codes for the listview? Thank you.

  • @mohamedrushan7705
    @mohamedrushan7705 Рік тому +3

    How to get the header on list box. . Isn't explained but finally on there how????

    • @ronedwardyap6940
      @ronedwardyap6940 11 місяців тому +1

      Same

    • @c0deblack
      @c0deblack 7 місяців тому

      same, i used “listbox1.clear” and this make listbox has no headers 😢

    • @angelou8633
      @angelou8633 6 місяців тому

      yeah, i use rowsource

    • @RAHIMPHYSICS
      @RAHIMPHYSICS 5 місяців тому

      @@angelou8633 How did you used that? I am trying but facing problem, can you please help?

    • @angelou8633
      @angelou8633 5 місяців тому

      @@RAHIMPHYSICS ua-cam.com/video/TuInj-DJ80A/v-deo.html

  • @MultiBoleba
    @MultiBoleba 10 місяців тому

    My code don't work, the informations are not showed in listbox after all, anyone have a tip for the solution?

  • @anhnhatnguyet4628
    @anhnhatnguyet4628 Рік тому

    vba excel, A1 type a few characters (if it supports Vietnamese, even better), B1 is the directory path to search, when found in B1 the word or excel file contains the same content as A1, then will return results from C1 down: the search path to the folder containing the word or excel file, the result contains content identical to A1 (including the file name). please help me

  • @binodrabha6633
    @binodrabha6633 Рік тому +1

    sir 10 above loop posible or not ?

  • @ahmadabunaqoos1602
    @ahmadabunaqoos1602 8 місяців тому +1

    this only work for 9 column ia any way to use more than 10 columns

  • @simplydoing9596
    @simplydoing9596 3 місяці тому

    the a= Len ... line is giving ERROR
    i don't know but error13
    why? how to correct

  • @anon-design
    @anon-design 5 місяців тому

    how i want add column detals like you with color green please see in last scene 12:55

  • @games-by2fy
    @games-by2fy Рік тому +1

    thank you so much

  • @javedakhtarjp
    @javedakhtarjp Рік тому

    sir , how to search text in the middle?

  • @asurajeff6316
    @asurajeff6316 Місяць тому

    How do you go pass 9 rows sir

  • @ahmetkilicarslan6178
    @ahmetkilicarslan6178 3 місяці тому

    How can I see more than 9 columns?

  • @melakutilahun3316
    @melakutilahun3316 Місяць тому +1

    thank you very much for clear presentation
    i write the code but nothing display on listbox2
    my column is 4
    =======
    Dim criterion
    Private Sub ComboBox1_Change()
    Dim c As Integer
    Dim column_headers
    column_headers = Array("A", "B", "C", "D")
    For c = 1 To 4
    If Sheet2.Cells(1, c).Value = Me.ComboBox1.Value Then
    criterion = column_headers(c - 1)
    End If
    Next
    Sheet2.Cells(1, "K").Value = criterion
    Me.ListBox2.Clear
    Me.TextBox1.Value = ""
    Me.TextBox1.SetFocus
    End Sub
    Private Sub TextBox1_Change()
    On Error Resume Next
    If Me.TextBox1.Text = "" Then
    Me.ListBox2.Clear
    Exit Sub
    End If
    Me.ListBox2.Clear
    Dim r, last_row As Integer
    last_row = Sheet2.Range(cell1).End(xlUp).Row
    For r = 2 To last_row
    a = Len(Me.TextBox1.Text)
    If UCase(Left(Sheet2.Cells(r, criterion).Value, a)) = UCase(Me.TextBox1.Text) Then
    With Me.ListBox2

    .AddItem Sheet2.Cells(r, "A").Value
    .List(.ListCount - 1, 1) = Sheet2.Cells(r, "B").Value
    .List(.ListCount - 1, 2) = Sheet2.Cells(r, "C").Value
    .List(.ListCount - 1, 3) = Sheet2.Cells(r, "D").Value
    End With
    End If
    Next

    End Sub
    Private Sub UserForm_Initialize()
    Dim c As Integer
    For c = 1 To 4
    Me.ComboBox1.AddItem Sheet2.Cells(1, c).Value
    Next
    With Me.ListBox2
    .ColumnCount = 4
    .ColumnWidths = "80;80;80;80"
    End With
    End Sub
    =====

  • @adonisfilea2529
    @adonisfilea2529 Рік тому

    Thank you very much

  • @dilipbera1970
    @dilipbera1970 Рік тому +1

    it shows only first column, please help

    • @medising3802
      @medising3802 Рік тому +1

      Go to the properties of your ListBox, and increase the ColumnCount to the number of Columns you want to see. Maybe this helps.

  • @tejsinghsarangdevot8198
    @tejsinghsarangdevot8198 3 місяці тому

    First row header is not fix how to solve

  • @melakutilahun3316
    @melakutilahun3316 Місяць тому +1

    no display on listbox

    • @hay_kel
      @hay_kel  Місяць тому +1

      first thanks for your comment. i think you need to initialize the event. it's explained from 4:24 to 5:34

  • @shahabali4518
    @shahabali4518 8 місяців тому

    Excellent

    • @hay_kel
      @hay_kel  6 місяців тому

      Thank you! Cheers!

  • @erol9000
    @erol9000 Рік тому +1

    Super

  • @FrankThoms-x3y
    @FrankThoms-x3y 25 днів тому

    keep getting a runtime error 424
    using just 6 columns
    Dim criterion
    Private Sub ComboBox1_Change()
    Dim c As Integer
    Dim column_headers
    column_headers = Array("A", "B", "C", "D", "E", "F")
    For c = 1 To 6
    If Sheet1.Cells(1, c).Value = Me.ComboBox1.Value Then
    criterion = column_headers(c - 1)
    End If
    Next
    Sheet1.Cells(1, "H").Value = criterion
    Me.ListBox1.Clear
    Me.TextBox1.Value = ""
    Me.TextBox1.SetFocus
    End Sub
    Private Sub TextBox1_Change()
    On Error Resume Next
    If Me.TextBox1.Text = "" Then
    Me.ListBox1.Clear
    Exit Sub
    End If
    Me.ListBox1.Clear
    Dim r, last_row As Integer
    last_row = Sheet1.Range("A10000").End(xlUp).Row
    For r = 2 To last_row
    a = Len(Me.TextBox1.Text)
    If UCase(Left(Sheet1.Cells(r, criterion).Value, a)) = UCase(Me.TextBox1.Text) Then
    With Me.ListBox1
    'MsgBox "Data Saved"

    .AddItem Sheet1.Cells(r, "A").Value
    .List(.ListCount - 1, 1) = Sheet1.Cells(r, "B").Value
    .List(.ListCount - 1, 2) = Sheet1.Cells(r, "C").Value
    .List(.ListCount - 1, 3) = Sheet1.Cells(r, "D").Value
    .List(.ListCount - 1, 4) = Sheet1.Cells(r, "E").Value
    .List(.ListCount - 1, 5) = Sheet1.Cells(r, "F").Value
    End With
    End If
    Next r

    End Sub
    Private Sub UserForm_Initialize()
    'making dropdown search Critria--------------------
    Dim c As Integer
    For c = 1 To 6
    Me.ComboBox1.AddItem Sheet1.Cells(1, c).Value
    Next
    With Me.ListBox1
    .ColumnCount = 6
    .ColumnWidths = "30,40,100,110,70,90"
    End With
    End Sub

  • @abdullahshafiq5924
    @abdullahshafiq5924 2 місяці тому +2

    Use "search for" 🙄

  • @suleymanturkmen2748
    @suleymanturkmen2748 Рік тому

    harika

  • @alim6770
    @alim6770 11 місяців тому

    can u send me the file

  • @manojsingal1136
    @manojsingal1136 9 місяців тому

    Na ismeaapne search की कोई coding ki hai kuch kaam nhii kar raha pagal बना रहे हो ना Sheet downloads की try के liye

  • @GopalBiswas-wt5ef
    @GopalBiswas-wt5ef Рік тому

    Sir
    31 March 2024 file expired हो जाएगा 1st अप्रैल open ओपन करने के लिए पासवर्ड देना होगा Excel VBA code कैसे लिखो लिखें