Happy New Year
And Thank you for taking a look at my problem.
What i have:
A Userform where I type a zip code in the textBox and while typing the ListBox shows the matching possibilities from a Range.
The Range is merged cells from a Table where I have Zip code in Col 1 and City in Col 2.
I can only search by ZipCode.
Example workBook Uploaded.
What I relly would like:
- A Userform where I would like a way to type in the textBox while the ListBox shows the values from a Table with Zip code in Col 1 and City in Col 2.
- While typing in TextBox the ListBox should only show matching possibilities.
- I would like the option of searching by either Zip Code or City.
- The ListBox should show Zip Code and Matching City (As in merged Cells on Sheet)
- A way to Select the value from the ListBox to the TextBox.
Any Help is much appreciated
A Snip of my code so far:
Private Sub Txb_POSTNR_BY_Change()
Dim a
Dim firstAddress As String
Me.Listbox_RESULTAT.Clear
With ThisWorkbook.Worksheets("ENGINE").Range("Q2:Q159")
Set a = .Find(Txb_POSTNR_BY.Text, LookIn:=xlValues, LookAt:=xlPart)
If Not a Is Nothing Then
firstAddress = a.Address
Do
Me.Listbox_RESULTAT.AddItem a.Text
Set a = .FindNext(a)
Loop While Not a Is Nothing And a.Address <> firstAddress
Else
MsgBox "No Match Found"
End If
End With
End Sub
Private Sub UserForm_Initialize()
Listbox_RESULTAT.List = ThisWorkbook.Worksheets("ENGINE").Range("Q2:Q159").Value
End Sub
Udklip.PNG
Bookmarks