Option Explicit
Dim lo As ListObject
Dim lr As ListRow
Dim n As Long
'Point 1
Public Sub InsertRowInTable_1()
Application.ScreenUpdating = False
Set lo = ActiveSheet.ListObjects(1)
Set lr = lo.ListRows.Add(AlwaysInsert:=True)
n = lo.ListRows.Count
With lr.Range
.Cells(1, 1).Value = Date
.Cells(1, 3).Value = lo.Range.Cells(n, 3) + 1
.Cells(1, 7).Value = Format(n, "00") & " - Saisir non-conformité"
End With
Set lr = Nothing: Set lo = Nothing
End Sub
'Point 2
Public Sub InsertRowInTable_2()
Dim tbl As Variant, v As Variant
Application.ScreenUpdating = False
tbl = Array(4, 5, 6, 9, 10, 11, 12, 13, 14)
Set lo = ActiveSheet.ListObjects(1)
Set lr = lo.ListRows.Add(AlwaysInsert:=True)
n = lo.ListRows.Count
With lr.Range
.Cells(1, 1).Value = Date
.Cells(1, 3).Value = lo.Range.Cells(n, 3) + 1
.Cells(1, 7).Value = Format(n, "00") & " - Saisir non-conformité"
For Each v In tbl
.Cells(1, v).Value = lo.Range.Cells(n, v)
Next
End With
Set lr = Nothing: Set lo = Nothing
End Sub
'Réinitialisation tableau en conservant les formules
'et la mise en forme.
Public Sub ResetTable()
Application.ScreenUpdating = False
Set lo = ActiveSheet.ListObjects(1)
If Not lo.DataBodyRange Is Nothing Then lo.DataBodyRange.Delete
Set lo = Nothing
End Sub