Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim Target2, RRow As Range
Dim TblMois As ListObject 'Tableau
Dim Y 'stockage temporaire saise
Set TblMois = Sh.ListObjects(1)
If Sh.ProtectContents = False Then Exit Sub
'Position de la saisie
If Target.Row = TblMois.DataBodyRange.Rows.Count + TblMois.HeaderRowRange.Row Then
'If Target.Cells(1, 1).Value = "" Then Exit Sub
If Not (Intersect(Sh.Range(Sh.Cells(1, Target.Column), Sh.Cells(Sh.Cells.Rows.Count, Target.Column)), TblMois.Range) Is Nothing) Then
Application.ScreenUpdating = False
Sh.Unprotect 'Password:=Monpass
Y = Target.Value
'Application.EnableEvents = false
For Each RRow In Target.Rows 'Ajout d'une ligne dans le tableau
TblMois.ListRows.Add
Next
Set Target2 = Target.Offset(-Target.Rows.Count, 0) 'Nouvelle position de la saisie
Target2 = Y
Target.Offset(0, 1).Select
'Sh.Protect UserInterfaceOnly:=True, Password:=Monpass
Sh.Protect
'Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End If
End Sub