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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| Private Sub UserForm_Initialize()
Dim nb_colonne As Long
nb_colonne = Worksheets("Sections-Auditeurs-Machines").Cells(1 & Columns.Count).End(xlToLeft).Column
'Affichage de la date du jour dans le label
Lbl_Date_Formulaire.Caption = Date
'Zone de liste vierge
ComboBox_Section.Value = ""
ComboBox_Auditeur.Value = ""
ComboBox_Poste.Value = ""
TextBox_Operateur.Value = ""
'Ajout des valeurs des cellules A1 à ... de l'onglet "Sections-Auditeurs"
For i = 1 To nb_colonne 'Liste des sections
ComboBox_Section.AddItem Worksheets("Sections-Auditeurs-Machines").Cells(1, i)
Next
no_lignes = 0
End Sub
Private Sub ComboBox_Section_Change()
'Zone de liste vidée (sinon les valeurs s'ajoutent)
ComboBox_Auditeur.Clear
ComboBox_Poste.Clear
Dim no_section As Integer, nom_auditeur As Integer, no_poste As Integer
'Numéro de la sélection "section" (ListIndex commence à 0)
no_section = ComboBox_Section.ListIndex + 1
'Nom des auditeurs de la colonne section choisie
nom_auditeur = Worksheets("Sections-Auditeurs-Machines").Cells(1, no_section).End(4).Row
'Nombre de lignes poste de la colonne section choisie
no_poste = Worksheets("Sections-Auditeurs-Machines").Cells(7, no_section).End(xlDown).Row
For i = 2 To nom_auditeur
ComboBox_Auditeur.AddItem Worksheets("Sections-Auditeurs-Machines").Cells(i, no_section)
Next
For i = 7 To no_poste
ComboBox_Poste.AddItem Worksheets("Sections-Auditeurs-Machines").Cells(i, no_section)
Next
End Sub
Private Sub CdB_Valider1_Click()
Dim i As Integer
'Contrôle du nom opérateur
For i = 1 To Len(TextBox_Operateur.Value)
If IsNumeric(Mid(TextBox_Operateur.Value, i, 1)) Then
MsgBox "Nom opérateur incorrect"
TextBox_Operateur.Value = ""
Exit Sub
End If
Next i
Application.ScreenUpdating = False
'Activation de la feuille de recueil
With Worksheets("Recueil données")
.Activate
'Détermine la première ligne vierge sous le tableau
no_lignes = Range("A" & Rows.Count).End(xlUp).Row + 1
'Copier la dernière ligne pour formater le remplissage
With Rows(no_lignes)
.FillDown
End With
'Remplir les cellules avec les valeurs des ComboBox et TextBox
Cells(no_lignes, 1) = Lbl_Date_Formulaire.Caption
Cells(no_lignes, 2) = ComboBox_Section.Value
Cells(no_lignes, 3) = ComboBox_Auditeur.Value
Cells(no_lignes, 4) = ComboBox_Poste.Value
Cells(no_lignes, 5) = TextBox_Operateur.Value
'Ouvrir le questionnaire suivant
Questionnaire1_Sécu.Show
'Fermer l'USF Formulaire
Unload Me
End With
End Sub
Private Sub CdB_Date_Click()
Calendrier.Show
' Me.Lbl_Date_Formulaire.Caption = Format(Dat, "dd/mm/yyyy")
Select Case Application.International(xlDateOrder)
'0 = mois-jour-année
'1 = jour-mois-année
'2 = année-mois-jour
Case 0
Me.Lbl_Date_Formulaire.Caption = Format(Dat, "mm/dd/yyyy")
Case 1
Me.Lbl_Date_Formulaire.Caption = Format(Dat, "dd/mm/yyyy")
Case 2
Me.Lbl_Date_Formulaire.Caption = Format(Dat, "yyyy/mm/dd")
End Select
End Sub
Private Sub CdB_Annuler1_Click()
delete_form ("Formulaire")
MsgBox "Etes-vous sûre de vouloir arrêter?", vbYesNo + vbQuestion
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
End Sub
Private Sub TextBox_Operateur_keyPress(ByVal keyAscii As MSForms.ReturnInteger) 'Force les MAJUSCULSES
keyAscii = Asc(UCase(Chr(keyAscii)))
End Sub |