Bonjour,
J'ai apporté quelques modifications et laisser le test seulement sur le numéro d'ordre qui est unique :
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MatRng As Range, StdRng As Range
Dim Lg As Long, LastLg As Integer
If Target.Row <> 5 And Target.Column <> 2 Then Exit Sub
With Range("A5").CurrentRegion
.Borders.LineStyle = xlThin
.BorderAround xlContinuous, xlThin, xlColorIndexAutomatic
End With
If Target.Value <> "" And Target.Row = 5 Then
With Sheets("Calc")
If Not IsNumeric(Application.Match(Target.Value, [Calc!5:5], 0)) Then
Set MatRng = .Range(.[C5], .Cells(.Rows.Count, 4).End(xlUp))
MatRng.Copy .Cells(5, .Columns.Count).End(xlToLeft).Offset(, 1)
.Cells(5, .Columns.Count).End(xlToLeft).Value = Target
End If
End With
ElseIf Target.Value <> "" And Target.Column = 2 Then
With Sheets("Calc")
If Not IsNumeric(Application.Match(Target.Offset(, -1).Value, [Calc!A:A], 0)) Then
'ici, ajout d'élèves
Lg = Target.Row
LastLg = .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Row
Range(Cells(Lg, 1), Cells(Lg, 2)).Copy .Cells(LastLg, 1)
Set StdRng = .Range(.[C9], .Cells(9, 3).End(xlToRight))
StdRng.Copy .Cells(LastLg, 3)
Else
'Modification nom
Lg = Application.Match(Target.Offset(, -1).Value, [Calc!A:A], 0)
MsgBox "Lg à écrire : " & Lg
.Range("A" & Lg) = Target.Offset(, -1)
.Range("B" & Lg) = Target
End If
End With
End If
End Sub