Multi liste sur listBox avec des données variables
Fermé
astreal
-
30 mai 2014 à 09:44
michel_m
Messages postés16602Date d'inscriptionlundi 12 septembre 2005StatutContributeurDernière intervention16 décembre 2023
-
30 mai 2014 à 11:51
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):
Private Sub Listtypologie_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
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
michel_m
Messages postés16602Date d'inscriptionlundi 12 septembre 2005StatutContributeurDernière intervention16 décembre 20233 313 Modifié par michel_m le 30/05/2014 à 11:52
Bonjour,
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