Bonjour,
J'ai reussi à lier 2 combobox mais je voudrai en rajouter une 3eme qui prendra les données de la colonne F en lien avec les 2 autres ( je sais pas si c'est clair ce que je mets!!!!)
Voici le code et le fichier
Merci d'avance
Option Explicit
Dim Ws As Worksheet
Dim NbLignes As Integer
Dim NoAction As Boolean
Private Sub ComboBox1_Change()
'Eviter d'envoyer la macro à chaque itération du remplissage du Combo1
If NoAction Then Exit Sub
Alim_Combo 2, ComboBox1.Value
End Sub
Private Sub Alim_Combo(CbxIndex As Integer, Optional Cible As Variant)
Dim j As Integer
Dim Obj As Control
Set Obj = Me.Controls("ComboBox" & CbxIndex)
Obj.Clear
NoAction = True
If CbxIndex = 1 Then
For j = 3 To NbLignes
Obj = Ws.Range("E" & j)
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("E" & j)
Next j
ElseIf CbxIndex = 2 Then
For j = 3 To NbLignes
If Ws.Range("E" & j) = CInt(Cible) Then
Obj = Ws.Range("D" & j)
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("D" & j)
End If
Next j
End If
On Error Resume Next
Obj.ListIndex = 0
On Error GoTo 0
NoAction = False
End Sub
Private Sub UserForm_Initialize()
Set Ws = Sheets("Base")
NbLignes = Ws.Range("D65536").End(xlUp).Row
'Remplissage du ComboBox1
Alim_Combo 1
Alim_Combo 2, ComboBox1.Value
Alim_Combo 3, ComboBox1.Value
End Sub
J'ai reussi à lier 2 combobox mais je voudrai en rajouter une 3eme qui prendra les données de la colonne F en lien avec les 2 autres ( je sais pas si c'est clair ce que je mets!!!!)
Voici le code et le fichier
Merci d'avance
Option Explicit
Dim Ws As Worksheet
Dim NbLignes As Integer
Dim NoAction As Boolean
Private Sub ComboBox1_Change()
'Eviter d'envoyer la macro à chaque itération du remplissage du Combo1
If NoAction Then Exit Sub
Alim_Combo 2, ComboBox1.Value
End Sub
Private Sub Alim_Combo(CbxIndex As Integer, Optional Cible As Variant)
Dim j As Integer
Dim Obj As Control
Set Obj = Me.Controls("ComboBox" & CbxIndex)
Obj.Clear
NoAction = True
If CbxIndex = 1 Then
For j = 3 To NbLignes
Obj = Ws.Range("E" & j)
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("E" & j)
Next j
ElseIf CbxIndex = 2 Then
For j = 3 To NbLignes
If Ws.Range("E" & j) = CInt(Cible) Then
Obj = Ws.Range("D" & j)
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("D" & j)
End If
Next j
End If
On Error Resume Next
Obj.ListIndex = 0
On Error GoTo 0
NoAction = False
End Sub
Private Sub UserForm_Initialize()
Set Ws = Sheets("Base")
NbLignes = Ws.Range("D65536").End(xlUp).Row
'Remplissage du ComboBox1
Alim_Combo 1
Alim_Combo 2, ComboBox1.Value
Alim_Combo 3, ComboBox1.Value
End Sub