Note: The other languages of the website are Google-translated. Back to English
Belépek  \/ 
x
or
x
Regisztráció  \/ 
x

or

Hogyan lehet automatikusan kitölteni, amikor beírja az Excel legördülő listát?

Ha van egy adatellenőrzési legördülő listája nagy elemekkel, akkor felfelé és lefelé kell görgetnie a listában, csak a megfelelő megtalálásához, vagy be kell írnia az egész szót közvetlenül a listamezőbe. Ha van módszer az automatikus kitöltés engedélyezésére, amikor beírja az első betűt a legördülő listába, akkor minden könnyebbé válik. Ez az oktatóanyag egy VBA-módszert nyújt a megvalósításhoz.

Automatikus kiegészítés, amikor beírja a legördülő listát VBA kóddal
További útmutatók a legördülő listához ...


Automatikus kiegészítés, amikor beírja a legördülő listát VBA kóddal

Kérjük, tegye a következőket, hogy a legördülő lista automatikusan kiegészüljön, miután beírta a megfelelő betűket a cellába.

Először be kell illesztenie egy kombinációs mezőt a munkalapba, és meg kell változtatnia annak tulajdonságait.

1. Nyissa meg azt a munkalapot, amely tartalmazza az automatikus kitöltéssel rendelkező legördülő lista cellát.

2. A Combo mező behelyezése előtt hozzá kell adnia a Fejlesztő fület az Excel szalaghoz. Ha a Fejlesztő fül jelenik meg a szalagon, váltás a 3. lépésre. Ellenkező esetben tegye a következőket: Kattintson filé > Opciók megnyitni Opciók ablak. Ebben Excel beállítások ablakban kattintson Szalag szabása a bal oldali ablaktáblában ellenőrizze a Fejlesztő jelölőnégyzetet, majd kattintson a gombra OK gomb. Lásd a képernyőképet:

3. kettyenés Fejlesztő > betétlap > Combo Box (ActiveX vezérlő).

4. Rajzoljon egy kombinációs mezőt az aktuális munkalapra. Kattintson a jobb gombbal, majd válassza a lehetőséget ingatlanok a jobb egérgombbal kattintva.

5. Ban,-ben ingatlanok párbeszédpanelt, kérjük, cserélje ki az eredeti szöveget a (Név) mezővel TempCombo.

6. Kapcsolja ki a Tervezési mód kattintson a gombra Fejlesztő > Tervezési mód.

Ezután alkalmazza az alábbi VBA kódot

7. Kattintson a jobb gombbal az aktuális lap fülre, majd kattintson a gombra Kód megtekintése a helyi menüből. Lásd a képernyőképet:

8. A nyílásban Microsoft Visual Basic for Applications ablakba, kérjük, másolja és illessze be az alábbi VBA kódot a munkalap Kód ablakába.

VBA kód: Automatikus kitöltés, amikor a legördülő listába gépel

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2020/01/16
    Dim xCombox As OLEObject
    Dim xStr As String
    Dim xWs As Worksheet
    Dim xArr
    
    Set xWs = Application.ActiveSheet
    On Error Resume Next
    Set xCombox = xWs.OLEObjects("TempCombo")
    With xCombox
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
    End With
    If Target.Validation.Type = 3 Then
        Target.Validation.InCellDropdown = False
        Cancel = True
        xStr = Target.Validation.Formula1
        xStr = Right(xStr, Len(xStr) - 1)
        If xStr = "" Then Exit Sub
        With xCombox
            .Visible = True
            .Left = Target.Left
            .Top = Target.Top
            .Width = Target.Width + 5
            .Height = Target.Height + 5
            .ListFillRange = xStr
            If .ListFillRange = "" Then
                xArr = Split(xStr, ",")
                Me.TempCombo.List = xArr
            End If
            .LinkedCell = Target.Address
        End With
        xCombox.Activate
        Me.TempCombo.DropDown
    End If
End Sub
Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case KeyCode
        Case 9
            Application.ActiveCell.Offset(0, 1).Activate
        Case 13
            Application.ActiveCell.Offset(1, 0).Activate
    End Select
End Sub

9. nyomja meg más + Q gombok egyszerre a Microsoft Visual Basic alkalmazások ablak.

Mostantól, amikor egy legördülő lista cellára kattint, a legördülő lista automatikusan felszólítja. Elkezdheti beírni a betűt, hogy a megfelelő elem automatikusan teljes legyen a kiválasztott cellában. Lásd a képernyőképet:

Jegyzet: Ez a kód nem működik egyesített celláknál.

Könnyen létrehozhat legördülő listát az Excel jelölőnégyzeteivel:

A Legördülő lista jelölőnégyzetekkel hasznossága Kutools for Excel segítségével könnyedén létrehozhat egy legördülő listát egy meghatározott tartományba tartozó jelölőnégyzetekkel, az aktuális munkalap, az aktuális munkafüzet vagy az összes megnyitott munkafüzettel az Ön igényei szerint.
Töltse le és próbálja ki most! (30 napos ingyenes nyomvonal)


Kapcsolódó cikkek:

Hogyan hozható létre legördülő lista több jelölőnégyzettel az Excelben?
Sok Excel felhasználó hajlamos többszörös jelölőnégyzetekkel rendelkező legördülő listát létrehozni annak érdekében, hogy egyszerre több elemet jelöljön ki a listából. Valójában nem hozhat létre több jelölőnégyzetet tartalmazó listát az adatellenőrzéssel. Ebben az oktatóanyagban két módszert mutatunk be az Excel több jelölőnégyzettel rendelkező legördülő lista létrehozására. Ez az oktatóanyag bemutatja a probléma megoldásának módszerét.

Hozzon létre legördülő listát az Excel másik munkafüzetéből
Nagyon egyszerű létrehozni egy adatellenőrzési legördülő listát a munkafüzetek munkalapjai között. De ha az adatellenőrzéshez szükséges listaadatokat egy másik munkafüzetben találja meg, mit tenne? Ebben az oktatóanyagban megtudhatja, hogyan hozhat létre részletesen egy legördülő listát az Excel másik munkafüzetéből.

Hozzon létre egy kereshető legördülő listát az Excelben
A sok értéket tartalmazó legördülő lista számára nem könnyű megtalálni a megfelelőt. Korábban bevezettük a legördülő lista automatikus kitöltésének módszerét, amikor az első betűt beírjuk a legördülő mezőbe. Az automatikus kiegészítés funkció mellett kereshetővé is teheti a legördülő listát a munka hatékonyságának növelése érdekében a megfelelő értékek megtalálásához a legördülő listában. A legördülő lista kereshetővé tételéhez próbálkozzon az oktatóanyag módszerével.

Automatikusan kitölti a többi cellát, amikor kiválasztja az értékeket az Excel legördülő listában
Tegyük fel, hogy létrehozott egy legördülő listát a B8: B14 cellatartomány értékei alapján. Bármelyik értéket választva a legördülő listából, azt szeretné, hogy a C8: C14 cellatartomány megfelelő értékei automatikusan feltöltődjenek egy kiválasztott cellában. A probléma megoldásához az oktatóanyagban szereplő módszerek kedveznek.

További útmutatók a legördülő listához ...


A legjobb irodai termelékenységi eszközök

A Kutools for Excel megoldja a legtöbb problémát, és 80% -kal növeli a termelékenységet

  • újrafelhasználás: Gyorsan helyezze be összetett képletek, diagramok és bármi, amit korábban használt; Cellák titkosítása jelszóval; Levelezőlista létrehozása és e-maileket küldeni ...
  • Super Formula Bar (könnyedén szerkeszthet több szöveget és képletet); Olvasás elrendezés (könnyen olvasható és szerkeszthető nagyszámú cella); Beillesztés a Szűrt tartományba...
  • Cellák / sorok / oszlopok egyesítése az adatok elvesztése nélkül; Osztott cellák tartalma; Kombinálja a duplikált sorokat / oszlopokat... megakadályozza az ismétlődő cellákat; Hasonlítsa össze a tartományokat...
  • Válassza a Másolat vagy az Egyedi lehetőséget Sorok; Válassza az Üres sorok lehetőséget (az összes cella üres); Super Find és Fuzzy Find sok munkafüzetben; Véletlenszerű kiválasztás ...
  • Pontos másolás Több cella a képletreferencia megváltoztatása nélkül; Automatikus referenciák létrehozása több lapra; Helyezze be a golyókat, Jelölőnégyzetek és még sok más ...
  • Kivonat szöveg, Szöveg hozzáadása, Eltávolítás pozíció szerint, Hely eltávolítása; Hozz létre és nyomtasson személyhívó részösszegeket; Konvertálás a cellatartalom és a megjegyzések között...
  • Szuper szűrő (mentse el és alkalmazza a szűrősémákat más lapokra); Haladó rendezés hónap / hét / nap, gyakoriság és egyebek szerint; Speciális szűrő félkövér, dőlt betűvel ...
  • Kombinálja a munkafüzeteket és a munkalapokat; Táblázatok egyesítése kulcsoszlopok alapján; Az adatok felosztása több lapra; Kötegelt konvertálás xls, xlsx és PDF...
  • Több mint 300 hatékony funkció. Támogatja az Office / Excel 2007-2019 és 365. Támogatja az összes nyelvet. Könnyen telepíthető a vállalkozásba vagy szervezetbe. 30 napos ingyenes próbaverzió. 60 napos pénzvisszafizetési garancia.
kte tab 201905

Az Office fül a füles felületet hozza az Office-ba, és sokkal könnyebbé teszi a munkáját

  • Füles szerkesztés és olvasás engedélyezése Wordben, Excelben és PowerPointban, Publisher, Access, Visio és Project.
  • Több dokumentum megnyitása és létrehozása ugyanazon ablak új lapjain, mint új ablakokban.
  • 50% -kal növeli a termelékenységet, és minden nap több száz kattintással csökkenti az egér kattintását!
officetab alja
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    stefany · 9 days ago
    hi, thanks for your code. I would like to autocomplete and make multiple selections in a drop down list. Can you help me please?, thank you
  • To post as a guest, your comment is unpublished.
    krish · 3 months ago
    Hello thanks for the code it works great.
    But i want to auto expand drop down list when i move to next cell by pressing enter key without clicking on arrow button (or) alt+down.
    Thanks in advance.
  • To post as a guest, your comment is unpublished.
    taras.samolyuk · 3 months ago
    Hello, is there a chance to add dependency to select date and in the next column to the proposed choices?
    • To post as a guest, your comment is unpublished.
      crystal · 3 months ago
      Good day,
      Would you provide a screenshot of what you are trying to do?
  • To post as a guest, your comment is unpublished.
    Christiam Alfonzo · 3 months ago
    como hago para agregar esta función
    =INDIRECTO("tabla1[columna]")
    al código
  • To post as a guest, your comment is unpublished.
    Danielle · 4 months ago
    I tried to use this method. I added the code. After that I add the range needed. Looks all fine. Then I test and the combobox dissapears directly after filling it. So the code works, but its not usable. What do I do wrong?
    Kind regards, Danielle
    • To post as a guest, your comment is unpublished.
      crystal · 4 months ago
      Hi,
      The code works well in my case. It is not easy to figure out the problem as you described above. Would you mind sending your worksheet to my email address?
  • To post as a guest, your comment is unpublished.
    coltan123 · 6 months ago
    Code is working , but data validation is not working. For example, when i set the data validation to be red/bue/yellow, it does not show error message when i type green
  • To post as a guest, your comment is unpublished.
    Mhyk · 6 months ago
    Hi I have some difficulties with my excel work. I would like to know if there is a method to autofill the cell I desire?
    Example
    1 = san pedro
    2 = santa rosa
    3 = calamba
    4 = san pablo
    and so on.

    I have a list with correspoding numbers. If I input number 1 in Cell A5 I would like it to automatically fill the Cell B5 with its corresponding list name (san pedro) and if I input 3 in A5, B5 will be = calamba.
    thank you. for the help, Im having trouble to find a solution to this hope to find answers.
    Thank you and God Bless.


    • To post as a guest, your comment is unpublished.
      crystal · 6 months ago
      Hi,
      Methods in this tutorial can do you a favor:
      How To Auto Populate Other Cells When Selecting Values In Excel Drop Down List?
      https://www.extendoffice.com/documents/excel/2400-excel-drop-down-list-auto-populate.html
  • To post as a guest, your comment is unpublished.
    Sisi · 7 months ago
    Hi Guys,


    I have made 2 different drop down list searchable in 1 sheet, the fist is working well but the second drop down list is showing me the formula of indirect as the second drop down list is indirect of the first. I have apply the VBA with combo and so on but still the second list is showing me the formula. how to I fix this?
  • To post as a guest, your comment is unpublished.
    Simona Muresan · 7 months ago
    Hi Guys,


    I have made 2 different drop down list searchable in 1 sheet, the fist is working well but the second drop down list is showing me the formula of indirect as the second drop down list is indirect of the first. I have apply the VBA with combo and so on but still the second list is showing me the formula. how to I fix this?

  • To post as a guest, your comment is unpublished.
    Juan Carlos · 8 months ago
    Hello, I have a problem with this method and I already use a list validated with an indirect function to refer to the range of a table and when applying this macro it shows me only the indirect formula in the list! How could I solve this problem?
  • To post as a guest, your comment is unpublished.
    Leonardo · 8 months ago
    Hi! Is it possible to disable the combo box scrolling list when I click on the cell? and leave it active only if I click on the arrow, thanks!
  • To post as a guest, your comment is unpublished.
    Leonardo · 8 months ago
    Hello, is it possible to replicate this in a complete column? I mean that each individual row of a column has this possibility or at least 1000 rows in a simple way. Thank you!
    • To post as a guest, your comment is unpublished.
      crystal · 8 months ago
      Hi Leonardo,
      The VBA works for all data validation drop down lists in the worksheet.
  • To post as a guest, your comment is unpublished.
    gurita_22 · 8 months ago
    If you use this method with one combobox/sheet i guess it's flawless.

    I used this method with three comboboxes on one sheet with 3 different ListFillRange.
    Dropdown keep showing up on different combobox than what i'm typing in.
    1. I type and select correctly from the first.
    2. When i go to second combo, the third dropdown pops up.(I have to select the"", as it is still empty)
    then i can search my second combobox.
    3. When i go to the third, the first dropdown pops up, I reselect the only item(as there is only one that was already selected in the first step)
    After this i can add the content in the third dropdown.



    All subs are on sheet1's vba window.
    Now i'm trying to spit code in different modules, but can't really make it work.
    Search works, but i always have to push the dropdown arrow to see available results to select. Dropdown doesn't pop up at all.

    using 365, but i have to make "sheet" work on excel 2010
  • To post as a guest, your comment is unpublished.
    Rohit · 8 months ago
    The command works when first applied. But after saving the file, when i reopen it the drop down itself disappears.
    • To post as a guest, your comment is unpublished.
      crystal · 8 months ago
      Hi Rohit,
      After applying the code, please save the workbook as an Excel Macro-Enabled Workbook before closing the file.
      • To post as a guest, your comment is unpublished.
        wendy · 2 months ago
        I have done that - saved as a macro-enabled workbook but it still all disappears when you close the file. Thanks, Wendy

  • To post as a guest, your comment is unpublished.
    ahmadzaid · 8 months ago
    I get an error message (1004) - the debug highlights ‘If Target.Validation.Type =3 Then’


    for info .. I use excel 2010

    • To post as a guest, your comment is unpublished.
      crystal · 8 months ago
      Hi,
      I tried the VBA in Excel 2010 and it works well.
      The drop down list should be data validation drop-down list which is created by clicking Data > Data Validation....
      • To post as a guest, your comment is unpublished.
        ahmad zaid · 8 months ago
        It's work in cell with list but when i move or tap or select any cell with no list ..the up message talked you about always show..

  • To post as a guest, your comment is unpublished.
    Carlos · 9 months ago
    Hi! Thanks for this code!

    I'm getting a compile error saying "variable not defined", it highlights the "cancel = true" line
    • To post as a guest, your comment is unpublished.
      crystal · 9 months ago
      Hi Carlos,
      Which Excel version are you using?
      • To post as a guest, your comment is unpublished.
        ahmadzaid · 8 months ago
        I get an error message (1004) - the debug highlights ‘If Target.Validation.Type =3 Then’


        fo info. I use excel 2010
      • To post as a guest, your comment is unpublished.
        Carlos · 9 months ago
        Hi. Office 365 Pro Plus
        • To post as a guest, your comment is unpublished.
          crystal · 9 months ago
          Hi Carlos,
          Remove the "cancel = true" line from the VBA, then try again.
  • To post as a guest, your comment is unpublished.
    Mitchell · 9 months ago
    Hi Crystal,

    Absolutely perfect and thank you for the code. However when i press enter the cell automatically goes down. How can I make the cell go to the right when I press enter?

    MItchell

  • To post as a guest, your comment is unpublished.
    Sergio · 10 months ago
    Hi,

    Is it possible to show the matches with the caracter your typping using this code and format of combox?

    Example:

    You have a list with Onion, Black Onion, Green Onion, Red Onion...

    And in the combox you type: "On", so the drop down list show all the values existing on the list that matchs with "On".

    Thanks
    • To post as a guest, your comment is unpublished.
      crystal · 9 months ago
      Hi Sergio,
      The method in this article can help you:
      How To Create A Searchable Drop Down List In Excel?
      https://www.extendoffice.com/documents/excel/2439-excel-drop-down-list-search.html
  • To post as a guest, your comment is unpublished.
    Reinaldo Yajure · 10 months ago
    When I applied this code to my worksheet, the Undo function is disabled (but only for this sheet in the workbook) -- is there a way to fix this so that undo can still be used?
    • To post as a guest, your comment is unpublished.
      crystal · 9 months ago
      Hi Reinaldo Yajure,
      Please apply the below VBA code. The problem is fixed. Sorry for the inconvenience.

      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      'Update by Extendoffice: 2020/05/19
      Dim xCombox As OLEObject
      Dim xStr As String
      Dim xWs As Worksheet
      Dim xArr

      Set xWs = Application.ActiveSheet
      On Error Resume Next
      If Target.Validation.Type = 3 Then
      Target.Validation.InCellDropdown = False
      Cancel = True
      xStr = Target.Validation.Formula1
      xStr = Right(xStr, Len(xStr) - 1)
      If xStr = "" Then Exit Sub
      Set xCombox = xWs.OLEObjects("TempCombo")
      With xCombox
      .ListFillRange = ""
      .LinkedCell = ""
      .Visible = False
      End With
      With xCombox
      .Visible = True
      .Left = Target.Left
      .Top = Target.Top
      .Width = Target.Width + 5
      .Height = Target.Height + 5
      .ListFillRange = xStr
      If .ListFillRange = "" Then
      xArr = Split(xStr, ",")
      Me.TempCombo.List = xArr
      End If
      .LinkedCell = Target.Address
      End With
      xCombox.Activate
      Me.TempCombo.DropDown
      End If
      End Sub
      Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      Select Case KeyCode
      Case 9
      Application.ActiveCell.Offset(0, 1).Activate
      Case 13
      Application.ActiveCell.Offset(1, 0).Activate
      End Select
      End Sub
      • To post as a guest, your comment is unpublished.
        Alistair · 7 months ago
        Hi there, this is a great solution, but for some reason, in the original code, the combox was hidden when the cell with the data validation was not active, and only visible when the cell was selected.
        With this code, we get undo back, which is perfect, but the combox does not auto-hide again when you click off.
        Do you have a solution for this?

        Thanks,

        Alistair
  • To post as a guest, your comment is unpublished.
    Sandeep Sharma · 10 months ago
    is there any way to increase the list size as it is showing up only 10 line items as i have 12 lines
    • To post as a guest, your comment is unpublished.
      crystal · 9 months ago
      Hi Sandeep Sharma,
      In the Properties dialog box of the Combo box (step 5 of this tutorial), please find the ListRows field and then change the number 8 to 12 under the Alphabetic tab.
  • To post as a guest, your comment is unpublished.
    Jonas · 11 months ago
    How can I Use Tab/Arrows/Enter to move to another cell once the current cell is filled? Thanks
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi Jonas,
      The Tab key and the Enter key can work normally. But can't help with the Arrows yet. Sorry for the inconvenience.
  • To post as a guest, your comment is unpublished.
    Ramitha · 11 months ago
    Hi . It is a very useful code . However , I cannot use it on horizontal tables which are is a reference for vertical drop downs. Is there a solution ?
  • To post as a guest, your comment is unpublished.
    K1000z · 1 years ago
    Hi Guys, are you able to share a code which i can use so that the autocomplete is used on the same column i.e H in every sheet within the workbook.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi,
      If you only want the column H to be affected, please try the below VBA code. But it is only available in one worksheet. For multiple sheets, you need to add the code to each sheet code window. Hope I can help.

      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      'Update by Extendoffice: 2019/8/14
      Dim xCombox As OLEObject
      Dim xStr As String
      Dim xWs As Worksheet
      Dim xArr
      Dim xRgStr As String
      Dim xRg As Range
      xRgStr = "H:H"

      Set xWs = Application.ActiveSheet
      On Error Resume Next
      Set xCombox = xWs.OLEObjects("TempCombo")
      With xCombox
      .ListFillRange = ""
      .LinkedCell = ""
      .Visible = False
      End With
      Set xRg = Intersect(Range(xRgStr), Target)
      If xRg Is Nothing Then Exit Sub
      If Target.Validation.Type = 3 Then
      Target.Validation.InCellDropdown = False
      Cancel = True
      xStr = Target.Validation.Formula1
      xStr = Right(xStr, Len(xStr) - 1)
      If xStr = "" Then Exit Sub
      With xCombox
      .Visible = True
      .Left = Target.Left
      .Top = Target.Top
      .Width = Target.Width + 5
      .Height = Target.Height + 5
      .ListFillRange = xStr
      If .ListFillRange = "" Then
      xArr = Split(xStr, ",")
      Me.TempCombo.List = xArr
      End If
      .LinkedCell = Target.Address
      End With

      xCombox.Activate
      Me.TempCombo.DropDown
      End If
      End Sub
      Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      Select Case KeyCode
      Case 9
      Application.ActiveCell.Offset(0, 1).Activate
      Case 13
      Application.ActiveCell.Offset(1, 0).Activate
      End Select
      End Sub
      • To post as a guest, your comment is unpublished.
        K1000z · 1 years ago
        Looks good.Thanks Crystal.
  • To post as a guest, your comment is unpublished.
    Billy · 1 years ago
    I get an error message (1004) - the debug highlights ‘If Target.Validation.Type =3 Then’
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Billy,
      Which Excel version are you using?
  • To post as a guest, your comment is unpublished.
    Angga S.P. · 1 years ago
    Woooooooowwwwww very useful, thankyou for sharing, god bless you
  • To post as a guest, your comment is unpublished.
    Big.Moe · 1 years ago
    Love this! Thanks so much. Got a small issue though. I like to tab from one cell to the next, but when I get to the cell with the drop down list, I can tab into the cell with no problem, but once I'm in, it won't let me tab back out. I have to physically move the mouse over and click into the next cell. Any fix for this? Kind of disrupts my rhythm, which is why I loved this autocomplete function in the first place. ;o)
  • To post as a guest, your comment is unpublished.
    Jerome · 1 years ago
    This is a great find, however, I have one little issue: I like to tab through the cells as I am entering data. I can tab into the cell with the drop down menu just fine, but once I'm in that cell, it stops me from exiting the cell with a tab. I have to physically move the mouse to the next cell and click on it. Is there a fix to be able to simply tab in and tab out of the autocomplete cell? Thanks.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Jerome,
      The Tab key still works well in my case after applying the code. Which Excel version are you using?
  • To post as a guest, your comment is unpublished.
    Alex C · 1 years ago
    I am using this code and a data validation with drop down lists for easy acces to what i need because i need the data to remain in excel boxes for other formulas to use it. However one of the combo boxes has almost 1500 items in the drop down and I'd like the user to be able to start typing a word in the combo box and get a list of suggestions to choose from based on the word entered for example if they type 'joh' in the combo box I want to show them a list of all the choices in the drop down that contains 'joh' so they can select the one they want. Now i can find the first 'joh' but it shows me like a list with what is near this 'joh', not specific all that contain 'joh'. Can i modify this code so can be used for what i want? Thank you and please help
  • To post as a guest, your comment is unpublished.
    Don P. · 1 years ago
    The Combobox works fine when 1-MatchEntryComplete is selected ,when I changed the selection to 2-fmMatchEntryNone in the Combobox properties it did not work ,i.e It does not auto select as I start typing. Is there a fix for this?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Don P.
      Only the 1-MatchEntryComplete option can make it work. Sorry can't help you for that.
  • To post as a guest, your comment is unpublished.
    Christian · 1 years ago
    It works. Thank you and God bless
  • To post as a guest, your comment is unpublished.
    Kuku · 1 years ago
    The code working but whenever I click on cell there the drop list auto prompt ,this make me unable to copy the contents and paste somewhere , how can I enable the copy and paste ?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Kuku,
      When the drop down list auto prompt, you can see the cursor displays inside the cell. It allows you to manually select the contents in the cell and then copy and paste with shortcut keys. Please have a try. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Charlis · 1 years ago
    I try copy the whole cell of droplisting after all selection , but whenever I click on cell it auto show the listing , this has cost me unable to copy the cells and paste the contents somewhere , any solutions , pls help ?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Charlis,
      Actually when the drop down list auto prompt, you can see the cursor displays inside the cell. It allows you to manually select the contents in the cell and then copy and paste with shortcut keys. Please have a try. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Eze · 1 years ago
    Hi! Does Anyone Know, how use this function just on a cell?
    • To post as a guest, your comment is unpublished.
      Thomas · 1 years ago
      Change line 16 to read "If ActiveCell.Address = "{ADDRESS e.g. $C$8}" Then"
  • To post as a guest, your comment is unpublished.
    ron · 1 years ago
    hi! I have tried the code, and it works fine, but it will not allow a macro to copy and paste.
  • To post as a guest, your comment is unpublished.
    RyanPlanteNJ · 1 years ago
    Hey guys, I'm having an issue where it doesn't let me type what I want to search for letter by letter. It just shows the whole word automatically and highlighted, and I start to type it moves it to the next closest word. is there anyway to not have it highlight the whole thing?
  • To post as a guest, your comment is unpublished.
    MartinK. · 1 years ago
    Great tutorial. Thank you.
  • To post as a guest, your comment is unpublished.
    me · 1 years ago
    Doesn't work. Please update.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi,
      Sorry for the inconvenience. Which Excel version are you using?
  • To post as a guest, your comment is unpublished.
    Nadine · 1 years ago
    hi when i use the VBA code on a column that has dates it changes it to a number. can anyone help
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Nadine,
      The problem didn't cause by the code.
      You need to format the column cells to date format before or after creating the drop-down list.
  • To post as a guest, your comment is unpublished.
    kennethaugng@gmail.com · 1 years ago
    Hi, Thaks for the code. Could I check if this formula can include an ignore blank function? This code took away my ignore blank function for my data validation. Please advise thanks
  • To post as a guest, your comment is unpublished.
    Ben · 1 years ago
    Hey, thanks for this! I have managed to get it to work, but like in Cartson's comment: I need to keep selections to the list. It populates ok, but if I enter a word not in the list, it still accepts it. The VBA code you replied with doesn't work unfortunately


    Like in Data Validation/locked cell, can it create some error or not allow the typed entry not in the list?


    Any help is much appreciated
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Ben,
      Sorry there are mistakes in the previous reply.
      After inserting the combo box, open its Properties window, change the Name to TempCombo, and then select 2 - fmStyleDropDownList from the Style field, and finally apply the below code. From now on, it won't allow entering word not in the list.

      Dim xRg As Range
      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      Dim xCombox As OLEObject
      Dim xStr As String
      Dim I As Long
      Dim xWs As Worksheet
      Set xWs = Application.ActiveSheet
      On Error Resume Next
      Set xCombox = xWs.OLEObjects("TempCombo")
      With xCombox
      .ListFillRange = ""
      .LinkedCell = ""
      .Visible = False
      End With
      If Target.Validation.Type = 3 Then
      Target.Validation.InCellDropdown = False
      Cancel = True
      xStr = Target.Validation.Formula1
      xStr = Right(xStr, Len(xStr) - 1)
      If xStr = "" Then Exit Sub
      Set xRg = Target
      With xCombox
      .Visible = True
      .Left = Target.Left
      .Top = Target.Top
      .Width = Target.Width + 5
      .Height = Target.Height + 5
      .ListFillRange = xStr
      .LinkedCell = Target.Address
      End With
      xCombox.Activate
      Me.TempCombo.DropDown
      End If
      End Sub
      Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      Dim xSel As Range
      On Error Resume Next
      Select Case KeyCode
      Case 13
      xRg.Offset(0, 1).Select
      End Select
      End Sub
      • To post as a guest, your comment is unpublished.
        Donald · 7 months ago
        Hi Cristal, great answer. Now if on the same worksheet I want to add another combo box that calls data from a third sheet, how would the code look like as I tried and got no result. I will appreciate your support. Donald
      • To post as a guest, your comment is unpublished.
        Jonas · 11 months ago
        It doesnt work for me either, I can still enter items that are not on the list. can you please help!
      • To post as a guest, your comment is unpublished.
        Rodrigo Fernandez La · 1 years ago
        Hello Crystal,
        I have tried to do this... but it doesn't work... I have 4 lists 2 independent and the other two depend on others... It only works with the first list
  • To post as a guest, your comment is unpublished.
    defrancodominic@gmail.com · 1 years ago
    Really great tutorial, thanks. Do you know how I can adapt this code to get it to work for merged cells? Thanks again.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi,
      The code does not work for merged cells yet. Sorry for the inconvenience.
  • To post as a guest, your comment is unpublished.
    Rob K · 1 years ago
    Hi every one i noticed a few questions asking if there is a way to limit this to one column but i didn't notice any answers, was this ever figured out? i have multiple drop downs in my work sheet and they are all being affected by the macro where i only want column H to be affected. Any help with this would be greatly appreciated.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Rob K,
      The below VBA code can help you solve the problem, please have a try and thank you for your comment.

      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      'Update by Extendoffice: 2019/8/14
      Dim xCombox As OLEObject
      Dim xStr As String
      Dim xWs As Worksheet
      Dim xArr
      Dim xRgStr As String
      Dim xRg As Range
      xRgStr = "H:H"

      Set xWs = Application.ActiveSheet
      On Error Resume Next
      Set xCombox = xWs.OLEObjects("TempCombo")
      With xCombox
      .ListFillRange = ""
      .LinkedCell = ""
      .Visible = False
      End With
      Set xRg = Intersect(Range(xRgStr), Target)
      If xRg Is Nothing Then Exit Sub
      If Target.Validation.Type = 3 Then
      Target.Validation.InCellDropdown = False
      Cancel = True
      xStr = Target.Validation.Formula1
      xStr = Right(xStr, Len(xStr) - 1)
      If xStr = "" Then Exit Sub
      With xCombox
      .Visible = True
      .Left = Target.Left
      .Top = Target.Top
      .Width = Target.Width + 5
      .Height = Target.Height + 5
      .ListFillRange = xStr
      If .ListFillRange = "" Then
      xArr = Split(xStr, ",")
      Me.TempCombo.List = xArr
      End If
      .LinkedCell = Target.Address
      End With

      xCombox.Activate
      Me.TempCombo.DropDown
      End If
      End Sub
      Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      Select Case KeyCode
      Case 9
      Application.ActiveCell.Offset(0, 1).Activate
      Case 13
      Application.ActiveCell.Offset(1, 0).Activate
      End Select
      End Sub
      • To post as a guest, your comment is unpublished.
        Dilshan · 15 days ago
        Hi,
        I am trying to pull that list data from another sheet but it does not work. below is my code
        Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        'Update by Extendoffice: 20190812
        Dim xCombox As OLEObject
        Dim xStr As String
        Dim xWs As Worksheet
        Dim xArr
        Dim xRgStr As String
        Dim xRg As Range
        xRgStr = "MAINInput!$D:$D"
        'MAINInput = sheet name where the list is available


        Set xWs = Application.ActiveSheet
        On Error Resume Next
        Set xCombox = xWs.OLEObjects("cmbEmployee")
        With xCombox
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
        End With
        Set xRg = Intersect(Range(xRgStr), Target)
        If xRg Is Nothing Then Exit Sub
        If Target.Validation.Type = 3 Then
        Target.Validation.InCellDropdown = False
        Cancel = True
        xStr = Target.Validation.Formula1
        xStr = Right(xStr, Len(xStr) - 1)
        If xStr = "" Then Exit Sub
        With xCombox
        .Visible = True
        .Left = Target.Left
        .Top = Target.Top
        .Width = Target.Width + 5
        .Height = Target.Height + 5
        .ListFillRange = xStr
        If .ListFillRange = "" Then
        xArr = Split(xStr, ",")
        Me.cmbEmployee.List = xArr
        End If
        .LinkedCell = Target.Address
        End With

        xCombox.Activate
        Me.cmbEmployee.DropDown
        End If
        End Sub
        Private Sub cmbEmployee_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        Select Case KeyCode
        Case 9
        Application.ActiveCell.Offset(0, 1).Activate
        Case 13
        Application.ActiveCell.Offset(1, 0).Activate
        End Select
        End Sub
      • To post as a guest, your comment is unpublished.
        Lucas Sienk · 1 years ago
        Thank you for this fix! One quick question: I running this code across multiple worksheets (31 to be exact) but it is only affecting one. I have the code the same for each worksheet limiting the columns but it doesn't seem to be working on the other sheets. Thanks in advance!
        • To post as a guest, your comment is unpublished.
          crystal · 1 years ago
          Hi,
          The above code can only work on one sheet at a time. Sorry for the inconvenience.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Rob K,
      The below VBA code can help you solve the problem. Thank you for your comemnt.

      Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      'Update by Extendoffice: 20190812
      Dim xCombox As OLEObject
      Dim xStr As String
      Dim xWs As Worksheet
      Dim xArr
      Dim xRgStr As String
      Dim xRg As Range
      xRgStr = "H:H" 'The range of cells containg drop-down lists you will make them autocomplete

      Set xWs = Application.ActiveSheet
      On Error Resume Next
      Set xCombox = xWs.OLEObjects("TempCombo")
      With xCombox
      .ListFillRange = ""
      .LinkedCell = ""
      .Visible = False
      End With
      Set xRg = Intersect(Range(xRgStr), Target)
      If xRg Is Nothing Then Exit Sub
      If Target.Validation.Type = 3 Then
      Target.Validation.InCellDropdown = False
      Cancel = True
      xStr = Target.Validation.Formula1
      xStr = Right(xStr, Len(xStr) - 1)
      If xStr = "" Then Exit Sub
      With xCombox
      .Visible = True
      .Left = Target.Left
      .Top = Target.Top
      .Width = Target.Width + 5
      .Height = Target.Height + 5
      .ListFillRange = xStr
      If .ListFillRange = "" Then
      xArr = Split(xStr, ",")
      Me.TempCombo.List = xArr
      End If
      .LinkedCell = Target.Address
      End With

      xCombox.Activate
      Me.TempCombo.DropDown
      End If
      End Sub
      Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      Select Case KeyCode
      Case 9
      Application.ActiveCell.Offset(0, 1).Activate
      Case 13
      Application.ActiveCell.Offset(1, 0).Activate
      End Select
      End Sub
  • To post as a guest, your comment is unpublished.
    Denise · 1 years ago
    When I paste the VBA code, do I need to change the Worksheet code editor to the Worksheet and Before Double Click? I changed those 2 fields and it populated codes into the code editor screen. So where do I paste the VBA code? after those? Before those? do I delete those 2 codes that autofill and then paste? I tried that but then the Worksheet changed back to General and Declarations and the code doesn't make my cells autofill. What am I doing wrong???
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Denise,
      Just right click the sheet tab (the worksheet contains the drop-down list you will make it autocomplete) and select View Code from the context menu, when the code editor opening, paste the code directly into it.
  • To post as a guest, your comment is unpublished.
    Chandan Mehta · 1 years ago
    How can i use same list for another combo box, do i need to write same code for another combo box, as i require 10 combo box
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Chandan Mehta,
      You just need to create 10 data validation drop-down lists, and then follow the steps in the article to achieve it (only need one combo box in the whole operation).
  • To post as a guest, your comment is unpublished.
    Ayelet · 1 years ago
    Is there a way to make this searchable (so that it returns anything from the list that matches anywhere in text not just the beginning)?
  • To post as a guest, your comment is unpublished.
    RK · 1 years ago
    How can I set it to accept only the text in the list?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi RK,
      Sorry can't help you with that. Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Anthony · 1 years ago
    How can the code be modified such that pressing SHIFT + TAB moves the cursor left in the row?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Anthony,
      Sorry can't help you with that. Thank you for your comment.
      • To post as a guest, your comment is unpublished.
        Anthony · 1 years ago
        No problem. I figured it out. Thanks, Crystal.
        • To post as a guest, your comment is unpublished.
          noob · 1 years ago
          Yeah want to know too
        • To post as a guest, your comment is unpublished.
          eeframe27 · 1 years ago
          Anthony, how did you end up doing this?
  • To post as a guest, your comment is unpublished.
    Parth · 1 years ago
    But what if i have dynamic list ? How can i provide the input to the combobox and refresh everytime the data is been added?
    • To post as a guest, your comment is unpublished.
      Conor · 1 years ago
      You'll have to make a table of the dynamic dataset and assign it to the 'ListFillRange' within the properties of your combobox.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Parth,
      Sorry can’t help you with this. Welcome to post any question about Excel to our forum: https://www.extendoffice.com/forum.html. You will get more Excel supports from our professional or other Excel fans.
  • To post as a guest, your comment is unpublished.
    MR Excel · 1 years ago
    Anyone looking for a simple dropdown input form in excell based on a list; i used Data.. "Data Validation" and then choose Allow: "List" and pointed the source at the list.
    This does not do the auto complete but does avoid any macros or dev and just uses native simple Excel features.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good day,
      The dropdown list mentioned in the post is the Data Validation dropdown list.
      After creating the Data Validation dropdown list in the worksheet, go ahead to apply the steps from 2 to 10 in the post.
  • To post as a guest, your comment is unpublished.
    Fabian · 1 years ago
    Buenas tardes dentro de esa lista predictiva tengo campos de lista con la función indirecto pero me elimina , como puedo conservar las funciones de lista conservando la búsqueda predictiva.