Multi liste sur listBox avec des données variables
astreal
-
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
J'ai des listes de personnel de plusieurs services (donc variable). Dans une listebox précédente on sélectionne le service. Ce programme doit me permettre de faire apparaître dans ma listbox le personnel du service afin de pourvoir sélectionner celui qui m'intéresse. Il faut ensuite que sont numéro apparaisse dans une case à part. Cela va m'aider pour la suite... Mais c'est là que je bug, j'ai toujours un 10 qui apparais. Pourriez-vous m'aider?
Voici le programme (c'est pas le plus simple , je ne suis que débutante):
J'ai des listes de personnel de plusieurs services (donc variable). Dans une listebox précédente on sélectionne le service. Ce programme doit me permettre de faire apparaître dans ma listbox le personnel du service afin de pourvoir sélectionner celui qui m'intéresse. Il faut ensuite que sont numéro apparaisse dans une case à part. Cela va m'aider pour la suite... Mais c'est là que je bug, j'ai toujours un 10 qui apparais. Pourriez-vous m'aider?
Voici le programme (c'est pas le plus simple , je ne suis que débutante):
Private Sub Listtypologie_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Range("z1") = "94" Then
Listtypologie.Clear
Listtypologie.AddItem Range("cb2")
Listtypologie.AddItem Range("cb3")
Listtypologie.AddItem Range("cb4")
Listtypologie.AddItem Range("cb5")
Listtypologie.AddItem Range("cb6")
Listtypologie.AddItem Range("cb7")
Listtypologie.AddItem Range("cb8")
Listtypologie.AddItem Range("cb9")
Listtypologie.AddItem Range("cb10")
Listtypologie.AddItem Range("cb11")
End If
If Range("z1") = "95" Then
Listtypologie.Clear
Listtypologie.AddItem Range("ce2")
Listtypologie.AddItem Range("ce3")
Listtypologie.AddItem Range("ce4")
Listtypologie.AddItem Range("ce5")
Listtypologie.AddItem Range("ce6")
Listtypologie.AddItem Range("ce7")
Listtypologie.AddItem Range("ce8")
Listtypologie.AddItem Range("ce9")
Listtypologie.AddItem Range("ce10")
Listtypologie.AddItem Range("ce11")
Listtypologie.AddItem Range("ce12")
Listtypologie.AddItem Range("ce13")
Listtypologie.AddItem Range("ce14")
Listtypologie.AddItem Range("ce15")
Listtypologie.AddItem Range("ce16")
End If
If Range("z1") = "96" Then
Listtypologie.Clear
Listtypologie.AddItem Range("cf2")
Listtypologie.AddItem Range("cf3")
Listtypologie.AddItem Range("cf4")
Listtypologie.AddItem Range("cf5")
Listtypologie.AddItem Range("cf6")
Listtypologie.AddItem Range("cf7")
Listtypologie.AddItem Range("cf8")
Listtypologie.AddItem Range("cf9")
Listtypologie.AddItem Range("cf10")
Listtypologie.AddItem Range("cf11")
Listtypologie.AddItem Range("cf12")
End If
If Range("z1") = "97" Then
Listtypologie.Clear
Listtypologie.AddItem Range("cd2")
Listtypologie.AddItem Range("cd3")
Listtypologie.AddItem Range("cd4")
Listtypologie.AddItem Range("cd5")
Listtypologie.AddItem Range("cd6")
Listtypologie.AddItem Range("cd7")
Listtypologie.AddItem Range("cd8")
Listtypologie.AddItem Range("cd9")
Listtypologie.AddItem Range("cd10")
Listtypologie.AddItem Range("cd11")
Listtypologie.AddItem Range("cd12")
Listtypologie.AddItem Range("cd13")
Listtypologie.AddItem Range("cd14")
Listtypologie.AddItem Range("cd15")
Listtypologie.AddItem Range("cd16")
Listtypologie.AddItem Range("cd17")
Listtypologie.AddItem Range("cd18")
Listtypologie.AddItem Range("cd19")
End If
If Range("z1") = "176" Then
Listtypologie.Clear
Listtypologie.AddItem Range("cc2")
Listtypologie.AddItem Range("cc3")
Listtypologie.AddItem Range("cc4")
Listtypologie.AddItem Range("cc5")
Listtypologie.AddItem Range("cc6")
Listtypologie.AddItem Range("cc7")
Listtypologie.AddItem Range("cc8")
Listtypologie.AddItem Range("cc9")
Listtypologie.AddItem Range("cc10")
Listtypologie.AddItem Range("cc11")
Listtypologie.AddItem Range("cc12")
End If
If Range("z1") = "177" Then
Listtypologie.Clear
Listtypologie.AddItem Range("ca2")
Listtypologie.AddItem Range("ca3")
Listtypologie.AddItem Range("ca4")
Listtypologie.AddItem Range("ca5")
Listtypologie.AddItem Range("ca6")
Listtypologie.AddItem Range("ca7")
Listtypologie.AddItem Range("ca8")
Listtypologie.AddItem Range("ca9")
Listtypologie.AddItem Range("ca10")
Listtypologie.AddItem Range("ca11")
Listtypologie.AddItem Range("ca12")
Listtypologie.AddItem Range("ca13")
End If
End Sub
Private Sub CommandButton1_Click()
Message = "Voulez vous vraiment supprimer les données de ce technicien?"
rep = MsgBox(Message, vbQuestion + vbYesNo, "Confirmation")
If rep = vbNo Then
Load UserForm5
End If
If rep = vbYes Then
Range("cg1").ClearContents
If listboxListtypologieValue <> Range("ca2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("cb2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("cc2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("cc2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("cd2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("ce2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("cf2") Then
Range("cg1") = 1
If listboxListtypologieValue <> Range("ca3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("cb3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("cc3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("cc3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("cd3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("ce3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("cf3") Then
Range("cg1") = 2
If listboxListtypologieValue <> Range("ca4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("cb4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("cc4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("cc4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("cd4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("ce4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("cf4") Then
Range("cg1") = 3
If listboxListtypologieValue <> Range("ca5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("cb5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("cc5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("cc5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("cd5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("ce5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("cf5") Then
Range("cg1") = 4
If listboxListtypologieValue <> Range("ca6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("cb6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("cc6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("cc6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("cd6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("ce6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("cf6") Then
Range("cg1") = 5
If listboxListtypologieValue <> Range("ca7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("cb7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("cc7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("cc7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("cd7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("ce7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("cf7") Then
Range("cg1") = 6
If listboxListtypologieValue <> Range("ca8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("cb8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("cc8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("cc8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("cd8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("ce8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("cf8") Then
Range("cg1") = 7
If listboxListtypologieValue <> Range("ca9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("cb9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("cc9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("cc9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("cd9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("ce9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("cf9") Then
Range("cg1") = 8
If listboxListtypologieValue <> Range("ca10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("cb10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("cc10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("cc10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("cd10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("ce10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("cf10") Then
Range("cg1") = 9
If listboxListtypologieValue <> Range("ca11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("cb11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("cc11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("cc11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("cd11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("ce11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("cf11") Then
Range("cg1") = 10
If listboxListtypologieValue <> Range("ca12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("cc12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("cc12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("cd12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("ce12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("cf12") Then
Range("cg1") = 11
If listboxListtypologieValue <> Range("ca13") Then
Range("cg1") = 12
If listboxListtypologieValue <> Range("cd13") Then
Range("cg1") = 12
If listboxListtypologieValue <> Range("ce13") Then
Range("cg1") = 12
If listboxListtypologieValue <> Range("cd14") Then
Range("cg1") = 13
If listboxListtypologieValue <> Range("ce14") Then
Range("cg1") = 13
If listboxListtypologieValue <> Range("cd15") Then
Range("cg1") = 14
If listboxListtypologieValue <> Range("ce15") Then
Range("cg1") = 14
If listboxListtypologieValue <> Range("cd16") Then
Range("cg1") = 15
If listboxListtypologieValue <> Range("ce16") Then
Range("cg1") = 15
If listboxListtypologieValue <> Range("cd17") Then
Range("cg1") = 16
If listboxListtypologieValue <> Range("cd18") Then
Range("cg1") = 17
If listboxListtypologieValue <> Range("cd19") Then
Range("cg1") = 18
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Unload UserForm5
End Sub
A voir également:
- Multi liste sur listBox avec des données variables
- Fuite données maif - Guide
- Liste déroulante excel - Guide
- Trier des données excel - Guide
- Liste déroulante en cascade - Guide
- Liste code ascii - Guide
1 réponse
Bonjour,
tu pourrais peut-^tre simplifier l'affectation d'une valeur à la cellule rg1
à adapter à ton contexte (macro écrite sur petite maquette chez moi)
Michel
tu pourrais peut-^tre simplifier l'affectation d'une valeur à la cellule rg1
à adapter à ton contexte (macro écrite sur petite maquette chez moi)
Sub xxx()
cherche = "blabla12"
If Application.CountIf(Range("C2:F21"), cherche) + 0 Then GoTo erreur
For Each cellule In Range("C2:F21")
If cellule = cherche Then Exit For
Next
Range("G1") = cellule.Row - 1
Exit Sub
erreur:
MsgBox cherche & " inconnu", vbCritical
End Sub
Michel