Option Explicit
Const form$ = "dd/mm/yyyy hh:mm" 'format modifiable
Dim nom$, F As Worksheet, lig& 'mémorise les variables
Private Sub CommandButton1_Click()
F.Cells(lig, 1) = nom
F.Cells(lig, 2) = CDate(Label4)
If Label5 <> "" Then F.Cells(lig, 3) = CDate(Label5)
Unload Me 'ferme l'UserForm
End Sub
Private Sub UserForm_Initialize()
nom = Application.UserName
Label1 = nom
Set F = Feuil1 'CodeName à adapter
F.Protect "toto", UserInterfaceOnly:=True
For lig = 3 To F.[A1].CurrentRegion.Rows.Count
If F.Cells(lig, 1) = nom And F.Cells(lig, 2) <> "" And F.Cells(lig, 3) = "" Then
Label4 = Format(F.Cells(lig, 2), form)
Label5 = Format(Now, form)
Exit Sub
End If
Next
Label4 = Format(Now, form)
Label5 = ""
End Sub