Microsoft 365 UserForm / Combobox / ListBox / erreur d'execution 13

sebpecoud

XLDnaute Nouveau
Bonjour,

Ci-joint mon code :
VB:
Private Sub UserForm_Initialize()
Dim D As Object, I As Integer
Me.ListBox1.ColumnCount = 6
Me.ListBox1.ColumnWidths = "98;98;98;98;98;98"
Me.ListBox1.Width = 300
Set F = Sheets("Traitement")
TC = F.Range("A1").CurrentRegion
Set D = CreateObject("Scripting.Dictionary")
For I = 1 To UBound(TC, 1)
    D(TC(I, 1)) = ""
Next I
Me.ComboBox1.List = D.keys
Me.TextBox1.Visible = True
Me.CommandButton1.Visible = True
End Sub
Private Sub ComboBox1_Change()
Dim I As Integer
For I = 1 To UBound(TC, 1)
[COLOR=#fac51c]   If TC(I, 1) = Me.ComboBox1.Value Then (=> erreur Type 13 "incompatibilité de type"[/COLOR]
         Me.ListBox1.AddItem TC(I, 1)
         Me.ListBox1.List(ListBox1.ListCount - 1, 1) = TC(I, 1)
         Me.ListBox1.List(ListBox1.ListCount - 1, 2) = TC(I, 2)
         Me.ListBox1.List(ListBox1.ListCount - 1, 3) = TC(I, 3)
         Me.ListBox1.List(ListBox1.ListCount - 1, 4) = TC(I, 4)
         Me.ListBox1.List(ListBox1.ListCount - 1, 5) = TC(I, 5)
         Me.ListBox1.List(ListBox1.ListCount - 1, 6) = TC(I, 6)
    End If
Next I
End Sub

Ce que je veux faire avec ce code :
Dans un premier temps dans afficher dans mon Combobox1 le texte de la colonne A de la feuille Traitement.
Capture.PNG

Puis afficher dans mon ListBox1, sur 6 colonnes, les infos correspondantes.

Je rencontre différent problème, celui signalé en Jaune.
Cependant, quand je remplace par If TC(I, 6) = Me.ComboBox1.Value Then alors je n'ai plus d'erreur mais je n'ai rien qui s'affiche dans mon ListBox1.

Voici mon tableau (j'ai évidemment caché les infos).
Capture.PNG


Je démarre dans UserForm.


Je vous remercie.

Sebastien
 

_Thierry

XLDnaute Barbatruc
Repose en paix
Bonjour @sebpecoud @jmfmarques , le Forum

Dans un premier temps dans afficher dans mon Combobox1 le texte de la colonne A de la feuille Traitement.
Puis afficher dans mon ListBox1, sur 6 colonnes, les infos correspondantes.

Sans example, pas sûr d'avoir capté, mais bon, dans l'exemple ci-joint
La Combo affiche les infos demandée dans la Listbox...

Bien à toi, à vous
@+Thierry
 

Pièces jointes

  • XLD_Sebpecoud_ComboBox_Alim_ListBox_Sample.xlsm
    27.5 KB · Affichages: 15

Discussions similaires

Réponses
4
Affichages
165
Réponses
17
Affichages
760

Statistiques des forums

Discussions
311 733
Messages
2 082 011
Membres
101 866
dernier inscrit
XFPRO