Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim ShDest As Worksheet
Dim trouve As Boolean
If Sh.Name = "Feuil2" Or Sh.Name = "Feuil3" Then
If Application.WorksheetFunction.CountA(Sh.Range("A" & Target.Row & ":D" & Target.Row)) = 4 _
And (Target.Column = 1 Or Target.Column = 2 Or Target.Column = 3 Or Target.Column = 4) Then
Set ShDest = Sheets("Feuil1")
With ShDest
Set nom = .Columns("A").Find(Sh.Range("A" & Target.Row).Value, LookIn:=xlValues, lookat:=xlWhole)
If nom Is Nothing Then
i = .Cells(65536, 1).End(xlUp).Row
Sh.Range("A" & Target.Row & ":D" & Target.Row).Copy .Range("A" & i + 1)
.Range("B" & i + 1).Value = Sh.Name
Else
Do
firstAddress = nom.Address
If nom.Offset(, 1).Value = Sh.Name Then
Sh.Range("A" & Target.Row & ":D" & Target.Row).Copy nom
nom.Offset(, 1).Value = Sh.Name
trouve = True
Else: Set nom = .Columns("A").FindNext(nom)
End If
Loop While Not nom Is Nothing And nom.Address <> firstAddress
If Not trouve Then
i = .Cells(65536, 1).End(xlUp).Row
Sh.Range("A" & Target.Row & ":D" & Target.Row).Copy .Range("A" & i + 1)
.Range("B" & i + 1).Value = Sh.Name
End If
End If
.Range("A1").CurrentRegion.Sort Key1:=.Range("A1:B1"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End If
End If
End Sub