Excel VBA ComBox Box with AutoComplete Search - Excel VBA Searchable Combox - Code Included
This Excel VBA example explains how to create searchable ComboBox with autocomplete feature.
you can get the relevant items as soon as you type in ComboBox and it autocomplete entries basis on matches.
Code is as follows :
Option Explicit
Private Comb_Arrow As Boolean
Private Sub ComboBox1_Change()
Dim i As Long
If Not Comb_Arrow Then
With Me.ComboBox1
.List = Worksheets("Data").Range("A2", Worksheets("Data").Cells(Rows.Count, "A").End(xlUp)).Value
.ListRows = Application.WorksheetFunction.Min(4, .ListCount)
.DropDown
If Len(.Text) Then
For i = .ListCount - 1 To 0 Step -1
If InStr(1, .List(i), .Text, vbTextCompare) = 0 Then .RemoveItem i
Next
.DropDown
End If
End With
End If
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Comb_Arrow = (KeyCode = vbKeyUp) Or (KeyCode = vbKeyDown)
If KeyCode = vbKeyReturn Then Me.ComboBox1.List = Worksheets("Data").Range _
("A2", Worksheets("Data").Cells(Rows.Count, "A").End(xlUp)).Value
End Sub
Пікірлер: 64
Merci pour cette vidéo, Elle m'a aidé à résoudre plusieurs problème de ma sélection
Very good tutorial appreciated. It is very good for beginners, hope to see more. Thanks
@ExcelDestination
3 жыл бұрын
thanks a lot!!
Thanks in a million. Great content. Awesome imagination.Grade: A++💥
@ExcelDestination
2 жыл бұрын
Our pleasure!
Muchisimas gracias desde "Ecuador"
it's worked for me, Thank you so muchhhhhhh
Thanks a lot sir, It is very good and it helped me a log.
its worl fine, thanks
Thanks a lot. Very helpful
@ExcelDestination
3 жыл бұрын
welcome
Thanks my pro u very good teacher
@ExcelDestination
3 жыл бұрын
Glad to hear that
Great Work, But you should add an option after selection to hit enter or tap to go to next cell
Vídeo excelente!
@ExcelDestination
2 жыл бұрын
Thanks
Thank you so mutch, Sir.
@ExcelDestination
3 жыл бұрын
You are most welcome
@josephkimote661
2 жыл бұрын
@@ExcelDestination 👍 Good things here, learning alot. Help me also do this: I have created a vba userform with autocomplete drop-down combobox search creteria but when I search based on a number or date column it is not able to search. It only searches text-data type columns. How can I modify the code to search for numbers, date and text or combination of any of the data types. Your response will be highly appreciated. Thanks in advance
thanks for this man.
@ExcelDestination
2 жыл бұрын
welcome
This is great and well explained, however I want to use this search facility in a textbox of a userform, can you show me what changed would be made to facilitate this please.
thanks it worked despite me thinking the referencing might be quite messed up. Can you please explain what the doe is actually doing. and what are those syntaxs or libraries or whatever they are called are working, with examples for each function.
Thank Yon Bhai..
مرسی
thanks brow
Thanks for the video, it's helped me quite a bit. I have a few questions too. 1) Is there a way to scroll through the list using the up/down arrow keys without having the Text change in the input field? 2) Is there a shorter line of code to replace the one for the .List? Having to type Worksheets("Data")... is a bit much and I feel like there should be a better way to do it. Maybe with Named Ranges. 3) Is it possible to do a Step Counter of +1 instead of -1? (I get an error when I try to) 4) I don't think this can be fixed, but the .ListRows doesn't update In-Real-Time as one is typing. The unused rows are visible still, but they are greyed out. Thanks again!
@user-oz4ko2vw4b
Жыл бұрын
هةقص٦ضفيض
Excellent video and very helpful too. I have couple of queries with this code. Hope you will help me out with that. 1. While we erase out all typed letter in combobox, dropdown list should not be visible. 2. if have two similar names in combobox dropdown list, then keydown does not work. Can you please suggest the solution of the above two queries?
thanks very muts ......
good job!
@ExcelDestination
3 жыл бұрын
thank you
hi sir i found error this line plz help If InStr(1, .List(i), .Text, vbTextCompare) = 0 Then
Thanks for the video, its help me a lot. Could you explain how to make combobox empty after entry data? Cause I tried this "combobox="" " But combobox always show the list. Thank you
Thanks
EXCELENT, SIR, I AM VERY VERY THANKFULL TO YOU
@ExcelDestination
2 жыл бұрын
You are most welcome
Can we filter data automatically using combobox in same destination like textbox.
Hi Sir, Need help, why i get error permission denied ?
How can I make the actual cells do what the combo box does?
Hi, thanks for the video! Could you tell us if you know how to extend the combo box to a whole column?
Sir, I have a worksheet. In sheet1, column 'AN' I have a list which is a name range. And I want a drop down list in Sheet3, B5 cell. How can I customize your code? Please help me.
@shoeb3818
4 ай бұрын
same question here
hello, thanks how would be the code if i want this in a combobox inside o userform, i have spent some time trying to adapt yours but i get multiple errors and i do not know how to continue, help much appreciated
Need help It's fantastic but when I type numbers with "/ " like 12/2 it automatically changed into date format like 12/20/2023 and not work backspace to remove year value . Please help 🙏
When changing to from Change() to Click() or Dropdownlist doesn't work any ideas?
Thank you, can we repeat this combo box in all the cells of the table
@ExcelDestination
3 жыл бұрын
yes
Sir how to add two columns in combobox and seach accordingly?
How to repeat same combo box in same coloum? Say avg 5000 times. If so please guide me to do it.
literrally did the same way copied created the excel .. still getting error 70 permission denied... where we are going wrong
How can I see all listed items when pressing down_arrow at the first start of using ComboBox? It shows nothing now. You should type some words before Box stars showing all the items...
sir what is the code for unique values for VBA ComBox Box with AutoComplete Search please Share
Hello Thanks for the video I have 3 lakhs plus item names in excel and want to fetch its correct and unique names from google Can you please suggest me how can I get unique names from google?
Hello Sir… really interesting work … I did the same in everything but I have a problem… error 438 … please help… thank you in advance
If we use indirect formula in drop down list then this coding is't work
Hi, this was a very helpful video. Is it possible to do the same thing combining 2 lists of data on 2 separate worksheets?
wow
@ExcelDestination
3 жыл бұрын
thank you
can you pls help me with one demo excel
not working with Userform combox..
Hello Excel Destination Please can you help me ? I send you by e-mail my file . Couse i truing do from your video but it not working .
Not good
Hello, thanks for this great Video! If i click on an Element inside the dropdown, the dropdown collapses and the Combobo don´t show the selected Item. If i Tab out & back in, the selection also disappears. Can you please have a look at my Code? ------------ Private Sub BaseSelect_Enter() ArtikelKat = "BASE" If Len(BaseFilter.Text) Then With BaseSelect .Clear .List = ComboFiltered(ArtikelKat, BaseFilter.Text) .DropDown End With Else With BaseSelect .Clear .List = ComboUnfiltered(ArtikelKat) .DropDown End With End If End Sub ----------- Private Sub BaseSelect_Change() ArtikelKat = "BASE" If Not Comb_Arrow Then With Me.BaseSelect .Clear .List = ComboUnfiltered(ArtikelKat) .DropDown If Len(.Text) Then .Clear .List = ComboFiltered(ArtikelKat, BaseSelect.Text) 'Function to return array with all multi inStr matches from .text entry .DropDown End If End With End If End Sub ------------ Private Sub BaseSelect_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Comb_Arrow = (KeyCode = vbKeyUp) Or (KeyCode = vbKeyDown) If KeyCode = vbKeyReturn Then Me.BaseSelect.List = ComboFiltered(ArtikelKat, BaseSelect.Text) End Sub -------------- Thanks in Advance! ;)