Dynamisk Search List DropDown in a Userform, ComboBox

  • Hi Forum.


    I found a Dynamic Search ComboBox video at the net, which show a dynamic list of all matching records, meanwhile they are typed.
    But the ComboBox is an In-Sheet ComboBox.


    Video link click here


    What I need instead is an In-Userform ComboBox and I tried to copy the codes into a Userform, but get a BUG in the NameRange List code.
    And then I think some settings is wrong in the ComboBox settings too, but I'm not sure.


    I had tried different forums, both Danish and English, but no solutions was send back.
    Maybe it's too difficult or not possible to make this dynamic list in a In-Userform, ComboBox, but I at least hope to get some response here.


    Any suggestions how to make the In-Userform ComboBox Dynamic ?
    I use Excel 2010.

    I'm not very good in VBA coding and will ask if it's possible to make the change in the attached file and send it back to me with an explanation.
    Then I'll take a look at it.

    Thank you in advance.


    Ib

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    I guess the main thing is to modify your Find in your Module to only find from Column C.


    In the Userform I used the List property.


    In the Module:

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    Hi Kenneth.


    I copied both the Userform and Module codes into my project, but got at BUG in the Sheet(1).CommandButton, UserForm1.Show, when trying to open the Userform.


    Then I took one code at the time.


    First the module code and it didn't made a BUG

    Code
    '*'Find text to the right
    'Set match = ws.Cells.Find(findMe)
    
    
           Set match = Worksheets("Ark1").Range("C2", Worksheets("Ark1").Range("C" & Rows.Count).End(xlUp)).Find(findMe)
           If match Is Nothing Then Exit Sub


    Next the Userform code, which made the BUG.

    Code
    'ComboBox1.RowSource = "Ark1!C2:C" & Range("C" & Rows.Count).End(xlUp).Row
    
    
    ComboBox1.List = WorksheetFunction.Transpose( _
        Worksheets("Ark1").Range("C2", Worksheets("Ark1").Range("C" & Rows.Count).End(xlUp)))


    I don't know if you tested the codes before posting them, but can it be because I use Excel 2010 and you maybe 2013 ?


    Ib

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    I've just done a similar thing

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    Hi Jindon.


    Hmmm - Tried to copy your code into my project, but it doesn't make the ComboBox-Search dynamic.


    If you open my project and try to type the letter h in the In-Sheet ComboBox, you'll get 11 dynamic results in the dropbox, all containing the letter h.
    - Claus Hansen
    - Peter Henrik Poulsen
    - Kevin Hansen
    - Ole Hermansen
    - Knud Aage Hansen
    - Morten Christensen
    - Claus Rydahl
    - Jonathan Pedersen
    - Ibrahim Kücakavci
    - Christian Pedersen


    If you then type the letter a, you'll reduce the result to 4 names containing the letters ha.
    - Claus Hansen
    - Kevin Hansen
    - Knud Aage Hansen
    - Jonathan Pedersen


    If you type hans, you'll get the 3 names, all ending at the surname Hansen.
    - Claus Hansen
    - Kevin Hansen
    - Knud Aage Hansen


    This is what I wish the In-Userform ComboBox could do and hope it's possible :idea:


    Ib

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    I've just done for UserForm not combobox on the sheet.
    And just chage

    Code
    For Each e In dic 
                        If UCase$(e) Like UCase$(.Value) & "*" Then AL.Add e 
                    Next


    to

    Code
    For Each e In dic 
                        If UCase$(e) Like "*" & UCase$(.Value) & "*" Then AL.Add e 
                    Next
  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    Wouw Jindon - It seems to work, but to be honest, I understand very little of the codes you made.


    I can see the ComboBox-list is taken from Column A and not from Column C.


    I also see in the Userform_Initialize, you define a = Sheets("ark1").[c1].CurrentRegion.Value
    - I don't know if this is the "not working code" ?
    - And if the [c1] is the right value, because the first name is in cell C2 ?




    I need to go from my computer now, but will be back later today.


    Ib

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    If you are taking about different workbook other than the one I uploaded, you may need to adjust the code.


    If you can't, I need to see your workbook with the same structure as your actual workbook.

  • Re: Dynamisk Search List DropDown in a Userform, ComboBox


    I have used Filter() for that type of thing in the past.
    e.g.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!