Excel VBA ComBox Box with AutoComplete Search - Excel VBA Searchable Combox - Code Included

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

Merci pour cette vidéo, Elle m'a aidé à résoudre plusieurs problème de ma sélection

kkhalilos
Автор

Very good tutorial appreciated. It is very good for beginners, hope to see more. Thanks

arunblr
Автор

Thanks in a million. Great content. Awesome imagination.Grade: A++💥

johng
Автор

it's worked for me, Thank you so

salehjawhar
Автор

Muchisimas gracias desde "Ecuador"

jaimecelorio
Автор

Thanks a lot sir, It is very good and it helped me a log.

sigmatabs
Автор

Great Work, But you should add an option after selection to hit enter or tap to go to next cell

lanzahealinghaircolorcareu
Автор

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.

malcolmt
Автор

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.

beenay
Автор

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!

theapexpredator
Автор

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?

ameetmehta
Автор

hi sir i found error this line plz help If InStr(1, .List(i), .Text, vbTextCompare) = 0 Then

GTECHGorakh
Автор

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

erdianadriani
Автор

Can we filter data automatically using combobox in same destination like textbox.

maheshlaxkar
Автор

Hi Sir,
Need help, why i get error permission denied ?

bonavkr
Автор

EXCELENT, SIR, I AM VERY VERY THANKFULL TO YOU

indranilsarkar
Автор

How can I make the actual cells do what the combo box does?

spritepot
Автор

Hi, thanks for the video!
Could you tell us if you know how to extend the combo box to a whole column?

Drum
Автор

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.

sadiqulalam
Автор

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

ehemad