maninwhite
XLDnaute Occasionnel
Bonjour à toutes et à tous
Je reviens vers vous afin de simplifier un code que j'ai écrit comme un débutant.
Ci dessous le userform :
Lien supprimé
Ce code permet de reporter les captions des checkboxs dans un tableau.
2è chose, comme vous pouvez le voir sur l'userform j'ai une colonne avec état et une avec Erreur critique.
Y a t'il une possibilité de dire :
Si aucun état sélectionné, msg box
Si aucune erreur critique sélectionnée, msg box.
Merci
Je reviens vers vous afin de simplifier un code que j'ai écrit comme un débutant.
Ci dessous le userform :
Lien supprimé
Ce code permet de reporter les captions des checkboxs dans un tableau.
Code:
Option Explicit
Private Sub CommandButton_suivant_Click()
With Sheets("report")
If CheckBox_précipitation.Value = True Then
.Cells(.Cells(Rows.Count, "Z").End(xlUp).Row + 1, "Z") = CheckBox_précipitation.Caption
Else
.Cells(.Cells(Rows.Count, "Z").End(xlUp).Row + 1, "Z") = "Non applicable"
End If
If CheckBox_frustration.Value = True Then
.Cells(.Cells(Rows.Count, "AA").End(xlUp).Row + 1, "AA") = CheckBox_frustration.Caption
Else
.Cells(.Cells(Rows.Count, "AA").End(xlUp).Row + 1, "AA") = "Non applicable"
End If
If CheckBox_fatigue.Value = True Then
.Cells(.Cells(Rows.Count, "AB").End(xlUp).Row + 1, "AB") = CheckBox_fatigue.Caption
Else
.Cells(.Cells(Rows.Count, "AB").End(xlUp).Row + 1, "AB") = "Non applicable"
End If
If CheckBox_excès_de_confiance.Value = True Then
.Cells(.Cells(Rows.Count, "AC").End(xlUp).Row + 1, "AC") = CheckBox_excès_de_confiance.Caption
Else
.Cells(.Cells(Rows.Count, "AC").End(xlUp).Row + 1, "AC") = "Non applicable"
End If
If CheckBox_inattention.Value = True Then
.Cells(.Cells(Rows.Count, "AD").End(xlUp).Row + 1, "AD") = CheckBox_inattention.Caption
Else
.Cells(.Cells(Rows.Count, "AD").End(xlUp).Row + 1, "AD") = "Non applicable"
End If
If CheckBox_distraction.Value = True Then
.Cells(.Cells(Rows.Count, "AE").End(xlUp).Row + 1, "AE") = CheckBox_distraction.Caption
Else
.Cells(.Cells(Rows.Count, "AE").End(xlUp).Row + 1, "AE") = "Non applicable"
End If
If CheckBox_ligne_de_tir.Value = True Then
.Cells(.Cells(Rows.Count, "AF").End(xlUp).Row + 1, "AF") = CheckBox_ligne_de_tir.Caption
Else
.Cells(.Cells(Rows.Count, "AF").End(xlUp).Row + 1, "AF") = "Non applicable"
End If
If CheckBox_perte.Value = True Then
.Cells(.Cells(Rows.Count, "AG").End(xlUp).Row + 1, "AG") = CheckBox_perte.Caption
Else
.Cells(.Cells(Rows.Count, "AG").End(xlUp).Row + 1, "AG") = "Non applicable"
End If
End With
Unload Me: reporter_un_incident_part4.Show
End Sub
2è chose, comme vous pouvez le voir sur l'userform j'ai une colonne avec état et une avec Erreur critique.
Y a t'il une possibilité de dire :
Si aucun état sélectionné, msg box
Si aucune erreur critique sélectionnée, msg box.
Merci
Dernière édition: