Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.[t_Entree]) Is Nothing Then Exit Sub
Dim Dc As New Scripting.Dictionary
Dim tS, tC, WshC As Worksheet, r As Range, t
Dim tb1(1 To 1, 1 To 3), tb2(1 To 1, 1 To 3)
Dim i%, ligne%
Set WshC = Worksheets("Suivi des stocks")
tS = Me.[t_Entree]
tC = WshC.[t_Stock]
For i = 1 To UBound(tC)
Dc(tC(i, 2)) = i
Next
For Each r In Target.Rows
t = Intersect(Me.[t_Entree], r.EntireRow)
If Not IsEmpty(t(1, 2)) Then
For i = 1 To 3
tb1(1, i) = t(1, i)
Next i
tb2(1, 1) = t(1, 9)
tb2(1, 2) = t(1, 10)
tb2(1, 3) = Me.Name
If Dc.Exists(t(1, 2)) Then
ligne = Dc(t(1, 2))
Else
With WshC.ListObjects("t_Stock")
.ListRows.Add
ligne = .ListRows.Count
End With
End If
With WshC.[t_Stock]
.Cells(ligne, 1).Resize(1, 3) = tb1
.Cells(ligne, 10).Resize(1, 3) = tb2
End With
End If
Next
End Sub