Note: The other languages of the website are Google-translated. Back to English
Đăng nhập  \/ 
x
or
x
Đăng ký  \/ 
x

or

Làm thế nào để tự động hoàn thành khi nhập trong danh sách thả xuống Excel?

Nếu bạn có danh sách thả xuống xác thực dữ liệu với các mục lớn, bạn cần cuộn lên và xuống trong danh sách chỉ để tìm mục thích hợp hoặc nhập trực tiếp toàn bộ từ vào hộp danh sách. Nếu có phương pháp cho phép tự động hoàn thành khi nhập ký tự đầu tiên trong danh sách thả xuống, mọi thứ sẽ trở nên dễ dàng hơn. Hướng dẫn này sẽ cung cấp một phương pháp VBA để giúp bạn đạt được nó.

Tự động hoàn thành khi nhập vào danh sách thả xuống với mã VBA
Các hướng dẫn khác cho danh sách thả xuống ...


Tự động hoàn thành khi nhập vào danh sách thả xuống với mã VBA

Vui lòng thực hiện như sau để danh sách thả xuống tự động hoàn thành sau khi nhập các chữ cái tương ứng vào ô.

Trước tiên, bạn cần chèn một hộp tổ hợp vào trang tính và thay đổi các thuộc tính của nó.

1. Mở trang tính có chứa ô danh sách thả xuống mà bạn muốn làm cho nó tự động hoàn thành.

2. Trước khi chèn hộp Tổ hợp, bạn cần thêm tab Nhà phát triển vào ruy-băng Excel. Nếu tab Nhà phát triển đang hiển thị trên ruy-băng của bạn, chuyển sang bước 3. Nếu không, hãy làm như sau: Tập tin > Các lựa chọn để mở Các lựa chọn cửa sổ. Trong này Tùy chọn Excel cửa sổ, nhấp Tuy Biên ruy-băng trong ngăn bên trái, chọn Nhà phát triển và sau đó bấm vào OK cái nút. Xem ảnh chụp màn hình:

3. nhấp chuột Nhà phát triển > Chèn > Hộp tổ hợp (Điều khiển ActiveX).

4. Vẽ một hộp tổ hợp trong trang tính hiện tại. Nhấp chuột phải vào nó và sau đó chọn Bất động sản từ menu chuột phải.

5. bên trong Bất động sản hộp thoại, vui lòng thay thế văn bản gốc trong (Tên) lĩnh vực với TempCombo.

6. Tắt Chế độ thiết kế bằng cách nhấp chuột Nhà phát triển > Chế độ thiết kế.

Sau đó, áp dụng mã VBA bên dưới

7. Nhấp chuột phải vào tab trang tính hiện tại và nhấp vào Mã Chế độ xem từ menu ngữ cảnh. Xem ảnh chụp màn hình:

8. Trong phần mở đầu Microsoft Visual Basic cho các ứng dụng cửa sổ, vui lòng sao chép và dán mã VBA bên dưới vào cửa sổ Mã của trang tính.

Mã VBA: Tự động điền khi nhập vào danh sách thả xuống

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. nhấn Khác + Q các phím đồng thời để đóng Ứng dụng Microsoft Visual Basic cửa sổ.

Từ bây giờ, khi nhấp vào một ô danh sách thả xuống, danh sách thả xuống sẽ tự động nhắc. Bạn có thể bắt đầu nhập chữ cái để tự động hoàn thành mục tương ứng trong ô đã chọn. Xem ảnh chụp màn hình:

Lưu ý: Mã này không hoạt động đối với các ô đã hợp nhất.

Dễ dàng tạo danh sách thả xuống với các hộp kiểm trong Excel:

Mô hình Danh sách thả xuống có hộp kiểm tiện ích của Kutools cho Excel có thể giúp bạn dễ dàng tạo danh sách thả xuống với các hộp kiểm trong một phạm vi được chỉ định, trang tính hiện tại, sổ làm việc hiện tại hoặc tất cả các sổ làm việc đã mở dựa trên nhu cầu của bạn.
Tải xuống và thử ngay bây giờ! (Đường mòn miễn phí 30 ngày)


Các bài liên quan:

Làm thế nào để tạo danh sách thả xuống với nhiều hộp kiểm trong Excel?
Nhiều người dùng Excel có xu hướng tạo danh sách thả xuống với nhiều hộp kiểm để chọn nhiều mục từ danh sách mỗi lần. Trên thực tế, bạn không thể tạo danh sách có nhiều hộp kiểm với Xác thực dữ liệu. Trong hướng dẫn này, chúng tôi sẽ chỉ cho bạn hai phương pháp để tạo danh sách thả xuống với nhiều hộp kiểm trong Excel. Hướng dẫn này cung cấp phương pháp để giải quyết vấn đề.

Tạo danh sách thả xuống từ một sổ làm việc khác trong Excel
Khá dễ dàng để tạo danh sách sổ xuống xác thực dữ liệu giữa các trang tính trong sổ làm việc. Nhưng nếu dữ liệu danh sách bạn cần để xác thực dữ liệu nằm trong một sổ làm việc khác, bạn sẽ làm gì? Trong hướng dẫn này, bạn sẽ học cách tạo danh sách drop fown từ một sổ làm việc khác trong Excel một cách chi tiết.

Tạo danh sách thả xuống có thể tìm kiếm trong Excel
Đối với một danh sách thả xuống với nhiều giá trị, việc tìm một giá trị thích hợp không phải là một công việc dễ dàng. Trước đây, chúng tôi đã giới thiệu một phương pháp tự động hoàn thành danh sách thả xuống khi nhập ký tự đầu tiên vào hộp thả xuống. Bên cạnh chức năng tự động hoàn thành, bạn cũng có thể làm cho danh sách thả xuống có thể tìm kiếm được để nâng cao hiệu quả làm việc trong việc tìm kiếm các giá trị thích hợp trong danh sách thả xuống. Để làm cho danh sách thả xuống có thể tìm kiếm được, hãy thử phương pháp trong hướng dẫn này.

Tự động điền các ô khác khi chọn giá trị trong danh sách thả xuống của Excel
Giả sử bạn đã tạo một danh sách thả xuống dựa trên các giá trị trong phạm vi ô B8: B14. Khi bạn chọn bất kỳ giá trị nào trong danh sách thả xuống, bạn muốn các giá trị tương ứng trong phạm vi ô C8: C14 được tự động điền vào một ô đã chọn. Để giải quyết vấn đề, các phương pháp trong hướng dẫn này sẽ giúp bạn.

Các hướng dẫn khác cho danh sách thả xuống ...


Các công cụ năng suất văn phòng tốt nhất

Kutools cho Excel giải quyết hầu hết các vấn đề của bạn và tăng 80% năng suất của bạn

  • Tái sử dụng: Chèn nhanh công thức phức tạp, biểu đồ và bất cứ thứ gì bạn đã sử dụng trước đây; Mã hóa ô với mật khẩu; Tạo danh sách gửi thư và gửi email ...
  • Super Formula Bar (dễ dàng chỉnh sửa nhiều dòng văn bản và công thức); Bố cục đọc (dễ dàng đọc và chỉnh sửa số lượng ô lớn); Dán vào Dải ô đã Lọc...
  • Hợp nhất các ô / hàng / cột mà không làm mất dữ liệu; Nội dung phân chia ô; Kết hợp các hàng / cột trùng lặp... Ngăn chặn các ô trùng lặp; So sánh các dãy...
  • Chọn trùng lặp hoặc duy nhất Hàng; Chọn hàng trống (tất cả các ô đều trống); Tìm siêu và Tìm mờ trong Nhiều Sổ làm việc; Chọn ngẫu nhiên ...
  • Bản sao chính xác Nhiều ô mà không thay đổi tham chiếu công thức; Tự động tạo tài liệu tham khảo sang Nhiều Trang tính; Chèn Bullets, Hộp kiểm và hơn thế nữa ...
  • Trích xuất văn bản, Thêm Văn bản, Xóa theo Vị trí, Xóa không gian; Tạo và In Tổng số phân trang; Chuyển đổi giữa nội dung ô và nhận xét...
  • Siêu lọc (lưu và áp dụng các lược đồ lọc cho các trang tính khác); Sắp xếp nâng cao theo tháng / tuần / ngày, tần suất và hơn thế nữa; Bộ lọc đặc biệt bằng cách in đậm, in nghiêng ...
  • Kết hợp Workbook và WorkSheets; Hợp nhất các bảng dựa trên các cột chính; Chia dữ liệu thành nhiều trang tính; Chuyển đổi hàng loạt xls, xlsx và PDF...
  • Hơn 300 tính năng mạnh mẽ. Hỗ trợ Office / Excel 2007-2019 và 365. Hỗ trợ tất cả các ngôn ngữ. Dễ dàng triển khai trong doanh nghiệp hoặc tổ chức của bạn. Đầy đủ các tính năng dùng thử miễn phí 30 ngày. Đảm bảo hoàn tiền trong 60 ngày.
tab kte 201905

Tab Office mang lại giao diện Tab cho Office và giúp công việc của bạn trở nên dễ dàng hơn nhiều

  • Cho phép chỉnh sửa và đọc theo thẻ trong Word, Excel, PowerPoint, Publisher, Access, Visio và Project.
  • Mở và tạo nhiều tài liệu trong các tab mới của cùng một cửa sổ, thay vì trong các cửa sổ mới.
  • Tăng 50% năng suất của bạn và giảm hàng trăm cú nhấp chuột cho bạn mỗi ngày!
officetab dưới cùng
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.
    Nate Bee · 2 years ago
    Hello, this worked great for me until I tried to create dependent drop-down lists. I wanted my selection for my drop down list in cell C2, for example, to depend on what I selected from my drop down list in cell A2. When I use an index-match formula to create this dependent drop-down in C2 (c/p the formula into the data validation interface with "List" as my allowed value), my index-match formula becomes part of the drop down list's options. Any ideas?
    • To post as a guest, your comment is unpublished.
      Kim · 1 years ago
      Hi Nate, I'm having the same issue. Did you find a solution?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Nate Bee,
      Sorry can't help you with that. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    sulabh chawla · 2 years ago
    works well for me. We all need to do data validation and create drop down first and then copy paste the macro. Thank you
  • To post as a guest, your comment is unpublished.
    Andrés Zapata · 2 years ago
    Good day, how to write words that are in the drop-down list, this option that you gave me serving me a lot, but additionally I would like to know how to write for example "ACETAMINO" 905701 ACETAMINOFEN AUTOMATED, and bring me all that word that contains my drop-down list
    With this option to consult the data requires me to start by typing in the order of the sentence, that is, having to write 905701 ... as I have a drop-down list of 1000 rows who consult the data we will have to memorize all the data and that would help.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Sorry can't fix the problem yet. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Andrés Zapata · 2 years ago
    Buen día, como hacer para escribir palabras que esten en la lista desplegable, esta opción que ustedes me brindan me sirvió mucho, pero adicional me gustaría saber la forma de escribir por ejemplo "ACETAMINO" 905701 ACETAMINOFEN AUTOMATIZADO, y me traiga todo lo relacionado con esa palabra que contenga mi lista desplegable.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Sorry can't fix the problem yet. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    victorjbm · 2 years ago
    Hi, bro. Thanks for the macro.
    I wanna know if you can edit this code to make autofill for emails.
    Ex: If my mail is victor@gmail.com and I write victor, and then @, when I write @ I got the common options (domains) for emails, like gmail.com, hotmail.com, outlook.com, etc.
    Is this possible?
    I would appreciate it very much.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      The code also works for email address. For the email address "victor@gmail.com", when typing "victor" or only the initial "v" into the cell, the entire email address "victor@gmail.com" will be atocomplete in the cell.
  • To post as a guest, your comment is unpublished.
    Will · 2 years 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 · 2 years ago
      Good day,
      Sorry can't fix the problem yet. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Melinda · 2 years ago
    And of course as soon as I type the question, I figure out a fix. If I don't change the name of my combo box to TempCombo but leave it as ComboBox21 which it is the default name it starts with, the combo box seems to work perfectly.
  • To post as a guest, your comment is unpublished.
    Melinda · 2 years ago
    My combo box is only visible in Design Mode. When I close design mode, it disappears. Is there an easy fix for this?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Melinda,
      In this case, the combo box works for the data validation drop down list.
      It only displays when selecting the cell that contains the drop down list.
  • To post as a guest, your comment is unpublished.
    Przem · 2 years ago
    Hi, thank you, great code. Is there a way to modify your code so that after typing "ana" I still will see "Nana" as a choice? Now it will narrow the choices to anything that starts with "ana". So now it is "ana*" but would be great if it could be "*ana*".
  • To post as a guest, your comment is unpublished.
    tkevink · 2 years ago
    How would I use this autocomplete feature and still being able to "tab"/"enter" to a new cell; and overwrite the already input information in the combo box?

    Right now I "tab"/"enter" and I need to delete the information in the cell in order to use the autocomplete again.
    • To post as a guest, your comment is unpublished.
      tkevink · 2 years ago
      Private Sub TempCombo_GotFocus()
      Me.TempCombo = Null
      End Sub



      I added this code and it allows me to delete what is in the cell. How would I just be able to overwrite what is there without deleting it?
      • To post as a guest, your comment is unpublished.
        crystal · 2 years ago
        Good Day,
        Thank you for your comment.
        But I don't really understand your question.
        The code you provide can help to clear the combo box cell value automatically when reselecting it. What do you mean overwrite it? Why not reselect or retype the new value in the combo box cell manually?
  • To post as a guest, your comment is unpublished.
    Kevin · 2 years ago
    How would I use this autocomplete feature and still being able to "tab"/"enter" to a new cell; and overwrite the already input information in the combo box?

    Right now I "tab"/"enter" and I need to delete the information in the cell in order to use the autocomplete again.
  • To post as a guest, your comment is unpublished.
    Reid Nickerson · 2 years ago
    Wow, that was EXACTLY what I was looking to do. Thanks so much for making it very straightforward and easy as pie.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      I’m glad I could help.
  • To post as a guest, your comment is unpublished.
    Bala · 2 years ago
    where can i enter the value for the list? And when i use data validation, i select the list from another sheet and based upon the selection, Vlookup fills up other cells? How can i do the same with combo box? Please explain
    • To post as a guest, your comment is unpublished.
      Bala · 2 years ago
      It works now. Thanks a lot.
  • To post as a guest, your comment is unpublished.
    Eve · 2 years ago
    Thank you soooo much. you've saved me a lot of time!
  • To post as a guest, your comment is unpublished.
    C.G. · 2 years ago
    Thanks for all great tips! The code isn't working when applied to a drop down list in Hebrew. Would you be able to help me with this? Thanks again!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi,
      Thank you for your comment.
      Sorry can't help you with that.
  • To post as a guest, your comment is unpublished.
    Pine · 2 years ago
    HI I like the code very much. But I was using named ranged as the Source (i.e. Source: =itemlist) for data validation and it works properly before I insert the VBA code. However after I insert the VBA code into my worksheet, my drop-down list shown only 1 selection i.e. 'itemlist' in the Source. I know it works well if I use excel cells e.g. A1:A16 as the Source when setting up data validation, but I was prefer for using named ranged as the Source.

    Is there any solutions? Thanks.
    • To post as a guest, your comment is unpublished.
      Boot Dat · 2 years ago
      Im having the exact same problem as you are facing, and i cant find a way to fix it. have you found a solution for it yet ?
  • To post as a guest, your comment is unpublished.
    alrik.yeep@gmail.com · 2 years ago
    Hi thanks a lot for the code, but the drop-down listing only appears for the data validation lists where the "Source" comes from reference to excel cells (e.g. cell B3:B10), for those where the "Source" listing is text-based (e.g. "Yes,No") the combo box will fail to show the list of options available although a manual input can still be done.

    Can you help out on this issue? Thanks.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Thanks for your comment. The code has been updated in the post, please have a try.
  • To post as a guest, your comment is unpublished.
    jennifer · 2 years ago
    when i go out of design mode my box disappears. also i dont see anywhere that you say to define or select the list?
  • To post as a guest, your comment is unpublished.
    Leonardo Ramos · 2 years ago
    Existe una forma para los formularios en word? Te lo agradecería muchísimo.
  • To post as a guest, your comment is unpublished.
    Harshit · 2 years ago
    How to skip blanks
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Harshit,
      All blanks need to be excluded while creating the drop down list.
      • To post as a guest, your comment is unpublished.
        gk · 2 years ago
        how do i change the source data for the list please?
  • To post as a guest, your comment is unpublished.
    James Trogdon · 2 years ago
    Thanks for this great code. I do have a question about if it would be possible to change the color of the linked cell if the person chooses a value from the list or if they type one of their own? For example, if I choose a value from the list the linked cell would show green text when I left the cell. If I typed my own value, then the linked cell would show red indicating I didn't choose one of the values from the list. Is this possible?
  • To post as a guest, your comment is unpublished.
    deepak_fer · 2 years ago
    Thanks for the wonderful code.
    I have a question.
    My cells in excel are of the nature x4x - y4y. The answers from the drop down are filtered only for the words matching the first half or starting with the alphabet xx but if i search for y4y, it will not show in the results.
    Is there a way to include the second half in the search as well?
    Also
    How can i modify the code so that the results shows all the alphabets from the search menu?
    Ex: If am searching for the word "example", but i input "ample", I would like to have the word "example" shown in the list as it contains the part of the search request.
  • To post as a guest, your comment is unpublished.
    lluis · 2 years ago
    thanks for the code, but it only works for me in the first list, I have some inderect lists after the first that don't show any value. Is there any solution? Thanks in advance. ;)
  • To post as a guest, your comment is unpublished.
    Lluis · 2 years ago
    thanks for the code, but it only works for me in the first list, I have some inderect lists after the first that don't show any value. Is there any solution. Thanks in advance. ;)
  • To post as a guest, your comment is unpublished.
    Derek · 2 years ago
    When I copy the VBA code into Visal Basic I cannot use copy paste anymore. I have to start Excel in normal mode to be able to copy,. How can I solve this?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Derek,
      The copy and paste functions work well in my case while using the code. Can you tell me which Office version you are using?
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Joe C. · 2 years ago
    Hello.
    How is this used for data entry? The primary reason to use data validation is to regulate your data input to have normalized results. I can think of how to use this for a search box, but not for what I would expect data validation to accomplish.
    Is there a way to put your data from the box into a new row?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Joe,
      Thanks for your comment.
      If you want to create a search box, please browse the below article to find the solution.

      How to create your own search box in Excel?
      https://www.extendoffice.com/documents/excel/4137-excel-create-a-search-box.html
  • To post as a guest, your comment is unpublished.
    Cwrivers · 2 years ago
    I have been using this code for months and love it, however I would like to use an if statement in my data validation source. I have the formula and it works without this vba code, but when I put the vba code back into the workbook the combo box doesn't show any values, just one blank box. Is there a way to incorporate an if statement for which list the code will look at.


    Example of my formula with bad formatting.
    =if(A1="x",named_range1,if(A1="y",named_range2))

    Thanks in advance!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi,
      Would you mind sending me your workbook? My email address: zxm@addin99.com.
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    munira · 2 years ago
    Thank you i have found out solution on your page after lots of trouble...you made it simple
    next challenge is to how to apply this to multiple cells?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      The code can also deal with multiple cells. Please have a try.
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    Marc · 2 years ago
    MERCI Infiniment, cela à règler beaucoup de cas semblable pour moi MERCI encore
  • To post as a guest, your comment is unpublished.
    Glen · 2 years ago
    Hi

    Thanks this worked for me...I used a Named Range in a table so had a bit of a hiccup but found this youtube video to help out https://www.youtube.com/watch?v=JwA2gAbEXic&feature=youtu.be

    I was curious to know why in your code that you made reference to the Combo

    Set xCombox = xWs.OLEObjects("TempCombo")


    But you then also just used Me.TempCombo.DropDown ? Was there a reason you just didnt use Me.TempCombo??
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Glen,
      In this case, we are using combo box to assist the auto-complete operation in data validation drop-down lists which already created in the worksheet. So I use the TempCombo.DropDown instead of TempCombo.
      Thanks for your comment.
  • To post as a guest, your comment is unpublished.
    leducyvan@gmail.com · 2 years ago
    Thanks for the code it work's great the only thing i seem to have a long list of blank space after my list is there a way to fix it so only my list is in the selection box
    Thanks
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Thanks for your comment. However, I didn't find any blank space after my list. It is possible that the drop-down list you have created including blank cells?
  • To post as a guest, your comment is unpublished.
    cchambers · 2 years ago
    I have 2 drop down lists I would like to convert to combo boxes, the second list values are dependent on the option selected in list 1. Further, i have 2 additional copies of this model, and would like each of the drop downs to work separately, to allow the user to select items to compare between each model. Is there a way to do this? When i try the steps outlined, each of the combo boxes are linked to the same list.
    • To post as a guest, your comment is unpublished.
      aandrea · 2 years ago
      Did you find a solution?
  • To post as a guest, your comment is unpublished.
    Jordi · 2 years ago
    Now its only searching for the first letters. Is it possible that it also search for complete words in the middle. Example PEFC Thermopal white. If i write white that it search for every row with white in it. It's the same question what @Rusty asked below ''I too would love something like Kumar indicates. Let's say one of the values in the drop down list is "John Goodman", is there anyway for the combo box to select and populate "John Goodman" as the user types just "Goodman"?
  • To post as a guest, your comment is unpublished.
    Ilze · 2 years ago
    Is it possible to assign the combo box to a specific data validation list using this code? I have more than 1 data validation list, but I only want the combobox to run with 1 specific data validation list. Would appreciate your help with this.
  • To post as a guest, your comment is unpublished.
    Dhold7327 · 2 years ago
    This doesn't seem to work if your data validation source is a name range within a table. Is there any way around that?
    • To post as a guest, your comment is unpublished.
      M. Amir Ashraf · 2 years ago
      "This doesn't seem to work if your data validation source is a name range within a table", I've also encountered the same problem when assigning the range thru VBA, however, it does seem to work if you assign it manually thru properties. It is annoying, but is a way out.
  • To post as a guest, your comment is unpublished.
    sompadlik · 2 years ago
    Hi, please help me to sort my issue with this code. Its working fine excpet one thing. When code is active excel wont let me to Copy and paste anything within the sheet. I tested on 2016 excel and its PERFECT! but at work we have 2007 excel... Its working but blocking copy and paste, why it is happening?
  • To post as a guest, your comment is unpublished.
    Hossam · 2 years ago
    Hi,

    This is a great macro, it worked with me fine, but how do I make the selection limited to the drop down list, I tried typing a random name which was not n the list and it got accepted.

    Thanks
    • To post as a guest, your comment is unpublished.
      J Hames · 1 years ago
      Having this same issue. Would love to know if you ever found a solution. Using this code for a database at my place of business. Used by several different employees with the idea of keeping down mistakes made through typos.
  • To post as a guest, your comment is unpublished.
    makosipper@gmail.com · 2 years ago
    Doesn't work with data validation for me. It seems to be focused on manually input drop down lists, not drop down generated when you use Data Validation.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good Day,
      It is a data validation drop down list provided in my case.
  • To post as a guest, your comment is unpublished.
    Carsten · 3 years ago
    OK got this to work with one problem, 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.

    I think it is something in the properties or VBA but not sure

    I also want to go to right cell after I hit enter as this is how I have it set up


    Thanks
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Dear Carsten,
      Please change the Style field to 2- fmSpecialEffectSunken in the Properties window of the Combo box, and then apply below VBA code. Hope I can help.

      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.
    Leandro · 3 years ago
    Hay alguna forma de mover el Combo? Como se encuentra directamente abajo de la lista desplegable al apretar Enter (una vez seleccionado el dato de dicha lista) te selecciona el Combo y termina mostrándote dos listas.
  • To post as a guest, your comment is unpublished.
    Alicia · 3 years ago
    This code seems to work sometimes for me - but not consistently. I have a document with multiple lists and it will auto populate most of the time but not all of the time. It seems to have a problem auto populating when there was no information in the cell prior - however data validation extends the entire column. Please advise a fix.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Alicia
      The code works well in my case. After auto populating, you need to clear the selection in the drop-down list to activate the next auto populate operation.
  • To post as a guest, your comment is unpublished.
    Martin Winlow · 3 years ago
    Hi,


    Could you please re-do this tutorial for Excel for Mac V15? MW
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Martin Winlow,
      The code haven't been tested in Mac system.
  • To post as a guest, your comment is unpublished.
    lonercom · 3 years ago
    I am using this script which works well with text but not with numerals. Here are some screenshots; 1 is the code, 2 is working by alpha, 3 is not working by Number. Ultimately I would like to be able to search by name or number (Col A or Col C). To work around the separate column issue, I copied the same date and transposed the data in those cells.

    Any help would be greatly appreciated.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Robert,
      What do you mean "is not working by number"? The code works well with text and numerals in my case. And I saw the case in your picture 3, the related whole number 40726 is automatically populated when you type 407 into the list box. Please let me know if I missed something in the case.
      • To post as a guest, your comment is unpublished.
        lonercom · 3 years ago
        Yes, however the data associated with that number (as in photo 2) does not populate.
  • To post as a guest, your comment is unpublished.
    Brittany · 3 years ago
    Hello, Is there anyway to make the drop down menu only show results that match what you're typing? For example; I am using this to select items for an invoice template and I have a dew wines that start with 'Gaja'. As I type Gaja the top result shows in my list of 20 results but the other options are below it and I have to use the mouse to scroll down to those or type the name of the wine until it is the only option. I would like to type 'G' and then be only shown all items with G. Then type 'Ga' and only see items with GA and so on.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Brittany,
      Hope method in this article: How to create a searchable drop down list in Excel? can help you.
      Please follow the link: https://www.extendoffice.com/documents/excel/2439-excel-drop-down-list-search.html
  • To post as a guest, your comment is unpublished.
    Pippa · 3 years ago
    I must be missing something but where do you specify what cell range actually compromises the dropdown list? I can do this using a combo box rather than activeX but can't get the autocomplete to work with a combo box.
    • To post as a guest, your comment is unpublished.
      Teddy · 3 years ago
      Pippa, i'm with you. I've followed the instructions but it does not work. Ive added the ListFIllRange & LinkedCell but it doesnt work so there is definitly something missing from these instructions
    • To post as a guest, your comment is unpublished.
      lonercom · 3 years ago
      .ListFillRange=
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Pippa,
      Sorry can't get your point.
  • To post as a guest, your comment is unpublished.
    Karan · 3 years ago
    Hi,

    My drop-down list has an custom format of mmm-yy. When I use the combo drop down it turns my entries i.e Jan-17 into number values . Applying a format doesn't fix that.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Karan,
      I tried exactly as you mentioned above, but it works well in my case. The combo box still keeps the date format.
      Which Office version do you use?
  • To post as a guest, your comment is unpublished.
    zikxxx · 3 years ago
    Hello,
    Is there any way to fill the list from a row ? When i try, only first entry is shown.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good Day,
      This problem cannot be solved.
      Any question about Excel, please don’t hesitate to post in our forum: https://www.extendoffice.com/forum.html.
      You will get more supports about Excel from our Excel professional.
  • To post as a guest, your comment is unpublished.
    zik · 3 years ago
    Hello,
    Is there any way to fill the list from a row ? when i try, only first entry is shown.
  • To post as a guest, your comment is unpublished.
    Mike · 3 years ago
    Greetings,

    when i try to use the code i get the message "Method or Data member not found". The highligted language is TempBombo in the Me.TempCombo.Dropdown line in the Worksheet_SelectionChange sub.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Mike,
      You need to change the name of the combo box to TempCombo in the Properties dialog box as we mentioned in above step 5.
  • To post as a guest, your comment is unpublished.
    arotolo · 3 years ago
    Is there a VBA code for this to work with merged cells?
    • To post as a guest, your comment is unpublished.
      arotolo · 3 years ago
      Surprisingly, the attached code actually is working on my merged cells!!! Great step by step. Thank you for putting this out here to help us!