XL 2019 Saisie automatique combobox

Monhtc

XLDnaute Occasionnel
Bonjour chers tous, j'ai cherché un peu partout sur ce forum comme ailleurs mais sans resultat concluant.
En effet j'ai un userform avec 3 combobox:
-combobox1
-combobox2
-combobox3
Ces 3 combobox sont liées (Rowsources) à un tableau et se présente comme suit:
combobox1: rowsources=NOM
combobox2: rowsources=POSTE
combobox3: rowsources=EQUIPE

ma préoccupation est la suivante:
Je souhaite qu'une fois, lorsque, l'une de ces informations est rentrée, sa correspondance dans les autres combobox s'affiche automatiquement.
Exemple si je choisi "Thiago" dans la combobox1 son poste s'affiche dans la combobox2 automatiquement ainsi que son equipe dans la combobox3
 

JM27

XLDnaute Barbatruc
bonjour
VB:
Private Sub ComboBox1_Change()
    If Me.ComboBox1.ListIndex <> -1 Then
        Me.ComboBox2.ListIndex = Me.ComboBox1.ListIndex
        Me.ComboBox3.ListIndex = Me.ComboBox1.ListIndex
    End If
End Sub

Private Sub ComboBox2_Change()
     If Me.ComboBox1.ListIndex <> -1 Then
        Me.ComboBox1.ListIndex = Me.ComboBox2.ListIndex
        Me.ComboBox3.ListIndex = Me.ComboBox2.ListIndex
    End If
End Sub

Private Sub ComboBox3_Change()
      If Me.ComboBox3.ListIndex <> -1 Then
        Me.ComboBox1.ListIndex = Me.ComboBox3.ListIndex
        Me.ComboBox2.ListIndex = Me.ComboBox3.ListIndex
    End If
End Sub
 

Monhtc

XLDnaute Occasionnel
Merci @JM27 le code marche à merveille désolé pour ce temps de latence avant de répondre, je le testais. Test à partir duquel j'ai constaté un décalage de ligne.
Est ce à cause de mon code en after update? le voici
VB:
Private Sub ComboBox1_AfterUpdate()
If ComboBox1.ListIndex > -1 Or ComboBox1 = "" Then Exit Sub
If MsgBox("Ajouter le nom à la liste ?", 4) = 7 Then ComboBox1 = "": Exit Sub
[NOMS].Cells(Application.CountA([NOMS]) + 1) = ComboBox1
ComboBox1.List = [NOMS].Cells(2).Resize(Application.CountA([]) - 1, 2).Value

End Sub


Private Sub ComboBox2_AfterUpdate()
If ComboBox2.ListIndex > -1 Or ComboBox2 = "" Then Exit Sub
If MsgBox("Ajouter le poste à la liste ?", 4) = 7 Then ComboBox2 = "": Exit Sub
[POSTES].Cells(Application.CountA([POSTES]) + 1) = ComboBox2
ComboBox2.List = [POSTES].Cells(2).Resize(Application.CountA([POSTES]) - 1, 2).Value

End Sub

Private Sub ComboBox3_AfterUpdate()
If ComboBox3.ListIndex > -1 Or ComboBox3 = "" Then Exit Sub
If MsgBox("Ajouter le contact à la liste ?", 4) = 7 Then ComboBox3 = "": Exit Sub
[EQUIPES].Cells(Application.CountA([EQUIPES]) + 1) = ComboBox3
ComboBox3.List = [EQUIPES].Cells(2).Resize(Application.CountA([EQUIPES]) - 1, 2).Value
End Sub
 

ChTi160

XLDnaute Barbatruc
Re
dans tes combobox
peut il selon le choix : Ex ComboBox1( Noms )
peut il y avoir plusieurs choix dans les autres ComboBox (Noms identiques et equipes differentes)
Si non pas besoin de trois Combobox.
il te faut des Combobox en cascades ,fait une recherche sur le forum
jean marie
 
Dernière édition:

Statistiques des forums

Discussions
311 725
Messages
2 081 943
Membres
101 849
dernier inscrit
florentMIG