C
Christine
Guest
Bonsoir,
Voici mon gros problème et probablement un petit pour vous : j'ai trois combobox et je dois relier chaque combobox entre eux, i.e. que lorsque je sélectionne une donnée dans le permier combobox, dans le deuxième, seul les données ayant un lien avec le premier doit apparaitre et de même pour le troisième.
Ex.:
a BB 1
a CC 2
b DD 3
b EE 4
c FF 5
c GG 6
Lorsque je choisi dans le premier combox a, le deuxième me donne comme possibilité BB et CC et si je choisi BB alors je n'ai comme possibilité 1.
En fouillant, voici ce que j'ai trouvé :
Private Sub UserForm_Initialize()
Dim L As Integer
Dim F As Integer
Dim P1 As New Collection, P2 As New Collection, P3 As New Collection
With Worksheets('Feuil1')
Tbl = Range('A2:C' & .Range('C65536').End(xlUp).Row)
End With
For L = 1 To UBound(Tbl, 1)
If Tbl(L, 1) <> '' Then
On Error Resume Next
P1.Add Tbl(L, 1), CStr(Tbl(L, 1))
On Error GoTo 0
End If
If Tbl(L, 2) <> '' Then
On Error Resume Next
P2.Add Tbl(L, 2), CStr(Tbl(L, 2))
On Error GoTo 0
End If
If Tbl(L, 3) <> '' Then
On Error Resume Next
P3.Add Tbl(L, 3), CStr(Tbl(L, 3))
On Error GoTo 0
End If
Next L
For Each item In P1
ComboBox1.AddItem item
Next item
For Each item In P2
ComboBox2.AddItem item
Next item
For Each item In P3
ComboBox3.AddItem item
Next item
End Sub
Est-ce qu'une âme charitable pourrait me dépanner ?
Merci beaucoup pour le temps que vous prendrez à m'aider.
Christine
Voici mon gros problème et probablement un petit pour vous : j'ai trois combobox et je dois relier chaque combobox entre eux, i.e. que lorsque je sélectionne une donnée dans le permier combobox, dans le deuxième, seul les données ayant un lien avec le premier doit apparaitre et de même pour le troisième.
Ex.:
a BB 1
a CC 2
b DD 3
b EE 4
c FF 5
c GG 6
Lorsque je choisi dans le premier combox a, le deuxième me donne comme possibilité BB et CC et si je choisi BB alors je n'ai comme possibilité 1.
En fouillant, voici ce que j'ai trouvé :
Private Sub UserForm_Initialize()
Dim L As Integer
Dim F As Integer
Dim P1 As New Collection, P2 As New Collection, P3 As New Collection
With Worksheets('Feuil1')
Tbl = Range('A2:C' & .Range('C65536').End(xlUp).Row)
End With
For L = 1 To UBound(Tbl, 1)
If Tbl(L, 1) <> '' Then
On Error Resume Next
P1.Add Tbl(L, 1), CStr(Tbl(L, 1))
On Error GoTo 0
End If
If Tbl(L, 2) <> '' Then
On Error Resume Next
P2.Add Tbl(L, 2), CStr(Tbl(L, 2))
On Error GoTo 0
End If
If Tbl(L, 3) <> '' Then
On Error Resume Next
P3.Add Tbl(L, 3), CStr(Tbl(L, 3))
On Error GoTo 0
End If
Next L
For Each item In P1
ComboBox1.AddItem item
Next item
For Each item In P2
ComboBox2.AddItem item
Next item
For Each item In P3
ComboBox3.AddItem item
Next item
End Sub
Est-ce qu'une âme charitable pourrait me dépanner ?
Merci beaucoup pour le temps que vous prendrez à m'aider.
Christine