Additem listbox in multiple columns

Solved
GrandJean -  
 GrandJean -
Hello,

Configuration: Windows XP / Chrome 30.0.1599.69

I am looking to populate a 2-column Listbox based on a letter search within a data range (city and postal code). Since a city name can have multiple postal codes, I want to be able to select the correct city, hence the display of the postal code. I can display the information if I only have one column, but not with two. I have conducted numerous tests, including with column too. I can display both pieces of information in one column if I do Me.Texte_4.AddItem c.Offset(1, 0) & " " & c.Offset(1, -1), but that doesn’t suit me because I only want to retrieve one of the two values, the name of the city.
I feel stuck, convinced that the solution is very simple. I would appreciate your help to move forward. Thank you in advance.

Here is my code:
dim plage

With Sheets("Tables")
finVille = .Cells(Rows.count, "E").End(xlUp).Row
Set plage = .Range(.Cells(10, "E"), .Cells(finVille + 1, "E"))

For Each c In plage
If UCase(c) Like UCase(Me.TB_Lettres) & "*" Then Me.Texte_4.AddItem
Me.Texte_4.List(, 0) = c.Offset(1, 0)
Me.Texte_4.List(, 1) = c.Offset(1, -1)

Next c
End With

End If

4 réponses

pijaku Posted messages 13513 Registration date   Status Modérateur Last intervention   2 771
 
Hello,

It is indeed a bit more complicated than that.
I recommend you check out this tutorial:
https://silkyroad.developpez.com/VBA/ControlesUserForm/#LII-G

--
Best regards,
Franck
1