F
François
Guest
Bonjour le forum,
J'ai trois combobox et lorsque le choix dans mon 3e est est fait, mais listbox devraient être remplis avec les informations mais cela ne fonctionne pas. Pourtant lorsque j'utilise le même code pour les listbox avec seulement un combobox tout est OK.
Voici le code pour test :
Private Sub ComboBox2_Change()
Dim c As Range, k As Long
Dim tabtemp As Variant
Dim L As Integer
Set myr3 = myr1.Offset(0, 2)
Do While th3.Count > 0
th3.Remove 1
Loop
On Error Resume Next
For Each c In myr3.Cells
If c.Offset(0, -2) & c.Offset(0, -1) = ComboBox1 & ComboBox2 Then
th3.Add c, CStr(c)
End If
Next
ComboBox3.Clear
For k = 1 To th3.Count
ComboBox3.AddItem th3(k)
Next k
With Worksheets('feuil1')
L = .Range('k15000:').End(xlUp).Row
tabtemp = .Range('A2:k' & L).Value
End With
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
ListBox8.Clear
For L = 1 To UBound(tabtemp, 1)
If tabtemp(L, 1) = CLng(ComboBox3.Value) Then
ListBox1.AddItem tabtemp(L, 2)
ListBox2.AddItem tabtemp(L, 3)
ListBox3.AddItem tabtemp(L, 4)
ListBox4.AddItem tabtemp(L, 5)
ListBox5.AddItem tabtemp(L, 6)
ListBox6.AddItem tabtemp(L, 7)
ListBox7.AddItem tabtemp(L, 8)
ListBox8.AddItem tabtemp(L, 9)
End If
Next L
End Sub
Où est mon erreur ?
Merci
J'ai trois combobox et lorsque le choix dans mon 3e est est fait, mais listbox devraient être remplis avec les informations mais cela ne fonctionne pas. Pourtant lorsque j'utilise le même code pour les listbox avec seulement un combobox tout est OK.
Voici le code pour test :
Private Sub ComboBox2_Change()
Dim c As Range, k As Long
Dim tabtemp As Variant
Dim L As Integer
Set myr3 = myr1.Offset(0, 2)
Do While th3.Count > 0
th3.Remove 1
Loop
On Error Resume Next
For Each c In myr3.Cells
If c.Offset(0, -2) & c.Offset(0, -1) = ComboBox1 & ComboBox2 Then
th3.Add c, CStr(c)
End If
Next
ComboBox3.Clear
For k = 1 To th3.Count
ComboBox3.AddItem th3(k)
Next k
With Worksheets('feuil1')
L = .Range('k15000:').End(xlUp).Row
tabtemp = .Range('A2:k' & L).Value
End With
ListBox1.Clear
ListBox2.Clear
ListBox3.Clear
ListBox4.Clear
ListBox5.Clear
ListBox6.Clear
ListBox7.Clear
ListBox8.Clear
For L = 1 To UBound(tabtemp, 1)
If tabtemp(L, 1) = CLng(ComboBox3.Value) Then
ListBox1.AddItem tabtemp(L, 2)
ListBox2.AddItem tabtemp(L, 3)
ListBox3.AddItem tabtemp(L, 4)
ListBox4.AddItem tabtemp(L, 5)
ListBox5.AddItem tabtemp(L, 6)
ListBox6.AddItem tabtemp(L, 7)
ListBox7.AddItem tabtemp(L, 8)
ListBox8.AddItem tabtemp(L, 9)
End If
Next L
End Sub
Où est mon erreur ?
Merci