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
|
Private Sub ComboBox1_Change()
lieu = ComboBox1.Value
Feuil1.ListObjects("Tableau1").Range.AutoFilter Field:=3, Criteria1:=lieu 'il me filtre le tableau par rapport à la colonne 3
End Sub
Private Sub ComboBox2_Change()
couleurs = ComboBox2.Value
Feuil1.ListObjects("Tableau1").Range.AutoFilter Field:=5, Criteria1:=couleurs 'il filtre à nouveau par la colonne 5
End Sub
Private Sub ComboBox3_Change()
competences = ComboBox3.Value
Feuil1.ListObjects("Tableau1").Range.AutoFilter Field:=6, Criteria1:=competences 'il filtre à nouveau par la colonne 6
End Sub
Private Sub CommandButton1_Click()
Dim Commentaire As String
Dim Cel As Range
nom = ComboBox4.Value 'là il ne filtre pas mais se sert de cette donnée pour la chercher dans le tableau
Set Cel = Feuil1.Range("7:7").Find(nom, , xlValues, xlWhole, , , False)
'il faut contrôler si un Range est bien retournée !
If Not Cel Is Nothing Then
colonne = Cel.Column
ligne = Cel.Row '<-- ici, c'est forcément 7 !
Commentaire = "" 'facultatif, mais au cas où tu relances la macro, ça va d'abord vider la variable
With Sheets("saisie")
For Each Cel In .Range(.Cells(ligne + 3, colonne + 2), .Cells(ligne + 1949, colonne + 2)) 'On pourrait limiter avec le specialcells, mais on va faire "brutal"
If Cel.Text <> "" Then Commentaire = Commentaire & "- " & Cel.Text & vbNewLine
Next Cel
End With
Sheets(ComboBox4.Value).Select
'charge le formulaire en mémoire
Load UserForm14
With UserForm14
'paramètre pour le label
.Label1.Caption = "Voici les commentaires obtenus par " & ComboBox4.Value & " dans la période " & ComboBox1.Value & " avec le niveau " & ComboBox2.Value & " pour la compétence " & ComboBox3.Value
'paramètre le TextBox
.TextBox1.MultiLine = True
.TextBox1.WordWrap = True
.TextBox1.Text = Commentaire 'affectation de texte
'affichage visuel du formulaire
.Show
End With
Else
MsgBox "La valeur '" & nom & "' n'a pas été trouvée !"
End If
End Sub |