السلام عليكم
يصبح كود الحفظ كالتالي
Private Sub EnregistrerA_Click()
With Sheet2
Application.ScreenUpdating = False
If TextBox5 = "" Then
MsgBox "Vous devez écrire la date", vbExclamation, ""
Exit Sub
End If
LR = .Cells(Rows.Count, "A").End(xlUp).Row + 1
For i = 1 To 9
.Cells(LR, i + 1).Value = Me.Controls("TextBox" & i).Value
.Range(.Cells(LR - 1, 1), .Cells(LR - 1, 10)).Copy
.Range(.Cells(LR, 1), .Cells(LR, 10)).PasteSpecial (xlPasteFormats)
.Cells(LR, 6).Value = CDate(TextBox5): .Cells(LR, 1).Value = LR - 11
.Range(.Cells(LR, 1), .Cells(LR, 10)).Borders.Value = 1
If CStr(TextBox9) = "A terme" Then .Range(.Cells(LR, 1), .Cells(LR, 10)).Interior.ColorIndex = 3
Next
End With
LR1 = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row
With Sheet2.Range("A12:J" & LR1)
.Sort .Columns(2), xlAscending
End With
j = LR1 - 11
With Sheet2.Range("A12")
.Value = 1
.Resize(j, 1).DataSeries
End With
A_terme
Application.ScreenUpdating = True
Application.CutCopyMode = False
End Sub