Pblm d'erreur d'execution 91 sur listbox à choix multiple conditionnée par une combobox
Bonjour,
Vous êtes mon dernier recours pour arriver à mes fins donc je me lance:
-Mon userform dispose d'une combobox et d'une listBox
-La combobox alimente les données de la liste box à partir du choix qui a été fait:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| 'Determination des valeurs de la combobox'
Private Sub UserForm_Initialize()
ComboBox1.AddItem "0 - Tomate"
ComboBox1.AddItem "1 -Choux"
ComboBox1.AddItem "2 - Bettrave"
ComboBox1.AddItem "3 - Salade"
ComboBox1.AddItem "4 - Pizza"
ComboBox1.AddItem "5 - Fromage"
ComboBox1.AddItem "6 - Tout"
End Sub
'Ici, j'alimente la listbox à partir du choix de la combobox'
Private Sub ComboBox1_Change()
If ComboBox1.Value = "0 - tomate" Then
ListBox1.RowSource = ("Feuil1!C26:C35")
ElseIf ComboBox1.Value = "1 - choux" Then
ListBox1.RowSource = ("Feuil1!F26:F32")
ElseIf ComboBox1.Value = "2 - bettrave" Then
ListBox1.RowSource = ("Feuil1!I26:I32")
ElseIf ComboBox1.Value = "3 - salade" Then
ListBox1.RowSource = ("Feuil1!M26:M32")
ElseIf ComboBox1.Value = "4 - pizza" Then
ListBox1.RowSource = ("Feuil1!R26:R32")
ElseIf ComboBox1.Value = ("5 - Fromage") Then
ListBox1.RowSource = ("Feuil1!V26:V30")
ElseIf ComboBox1.Value = "" Then
ListBox1.RowSource = ""
ElseIf ComboBox1.Value = "6 - Tout" Then
ListBox1.RowSource = ("")
End If
End Sub |
-Ensuite je voudrais que pour chaque choix de la listbox, une action s'execute: voici donc ce que j ai écris:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| Sub perimetre()
Dim ListBox1 As ListBox
If ListBox1.Value = ("APPUI ET EXPERTISE") Then
Call EtatmajAPPUIETEXPERTISE
End If
If ListBox1.Value = ("AQHSE") Then
Call EtatmajAQHSE
End If
If ListBox1.Value = ("COMMUNICATION") Then
Call EtatmajCOMMUNICATION
End If
If ListBox1.Value = ("DETACHES SYNDICAUX ET SOCIAUX") Then
Call Etatmajdetachesyndic
End If
If ListBox1.Value = ("DIRECTION") Then
Call EtatmajDirection
End If
If ListBox1.Value = ("ETAT MAJOR") Then
Call Etatmaj
End If
If ListBox1.Value = ("GESTION") Then
Call EtatmajGESTION
End If
If ListBox1.Value = ("LOGISTIQUE SECRETARIAT ASSISTANCE") Then
Call EtatmajLOGISTIQUESECRETARIATASSISTANCE
End If
If ListBox1.Value = ("Nouveau groupe") Then
Call EtatmajNouveaugroupe
End If
If ListBox1.Value = ("RESSOURCES HUMAINES") Then
Call EtatmajRESSOURCESHUMAINES
End If
If ListBox1.Value = ("CALVADOS") Then
Call OPEcalvados
End If
If ListBox1.Value = ("EURE") Then
Call OPEEure
End If
If ListBox1.Value = ("ORNE") Then
Call OPEOrne
End If
If ListBox1.Value = ("SEINE MARITIME") Then
Call OPEseinemaritime
End If
'etc(il y en a 20)'
End Sub |
Bien évidemment, le code ne marche pas et VBA surligne la partie
Code:
If ListBox1.Value = ("APPUI ET EXPERTISE") Then
et me renvoit l'erreur dexecution 91, en précisant que la variable objet ou variable de bloc with est non-definit
J'ai essayé avec des ifelse à la place des if ( sauf le premier en enlevant les end if intermédiaires), avec des select cases (mais même probleme à la ligne "selct case listbox1.value", en introduisant des variables intermédiaires , en changeant le LIstBox1.value en selected, rien n'y fait. Il semble que le programme ne trouve pas la valeur sélectionnée de ma listbox...
J'ai donc un grand besoin d'aide
Merci d'avance