PDA

View Full Version : Solved: auto complete based on the first and last name (combobox / UserForm)



elsg
05-10-2013, 02:25 PM
I have a userform with a combobox, and also have a spreadsheet "SheetNames" column "A" is a column with various names.
I would like to create a complete high.


example:

I have the following name (spreadsheet "SheetNames" column "A")
ABNER ANTONIO ANDRE DE Moura

I'd like a way I can enter any part of the name.

If I enter ANTONIO, then the code will search all ANTONIO, if you have more than 1 I will bring all if not auto complete ABNER ANTONIO ANDRE DE Moura.

If I enter Moura, then the code will search all Moura, if you have more than 1 I will bring all if not auto complete ABNER ANTONIO ANDRE DE Moura.

snb
05-11-2013, 02:01 AM
That's exactly what happens if you load all values into the combobox:


Private Sub Initialize()
combobox1.list=columns(1).specialcells(2).value
end sub

elsg
05-11-2013, 04:28 AM
sorry, nothing happens!!

see exemple in file

elsg
05-14-2013, 04:19 PM
anyone have any suggestions?

I'll be happy if someone could help me, thank you!!

elsg
05-18-2013, 10:39 AM
would be the same as the filter in excel 2010
please help me out!

mdmackillop
05-18-2013, 01:58 PM
I don't see how that would work with a combobox. Try this using a TextBox and a ListBox
Private Sub TextBox1_Change()
Dim x As String, r As Range
x = TextBox1
If Len(x) < 4 Then Exit Sub
ListBox1.Clear
With Sheets(1).Columns(1)
filtercriteria = "*" & x & "*"
.AutoFilter Field:=1, Criteria1:=filtercriteria
Set r = Range(.Cells(2, 1), .Cells(Rows.Count, 1).End(xlUp)).SpecialCells(xlCellTypeVisible)
.AutoFilter
End With
For Each CEL In r
ListBox1.AddItem CEL
Next
End Sub