Salut moli, jmd,
quand tu tapes une quantité, la macro calcule la présence ou non de la référence dans le tableau 'A COMMANDER'.
- si absente, la macro crée une nouvelle ligne avec référence et quantité ;
- si déjà présente, la quantité est mise à jour ;
- si ta quantité est nulle ou vide, elle supprime éventuellement la ligne du tableau ;
- les bordures sont ajustées à chaque changement.
Private Sub Worksheet_Change(ByVal Target As Range)
'
If Target.Count > 1 Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
'
iRowA = Range("A" & Rows.Count).End(xlUp).Row
iRowK = Range("K" & Rows.Count).End(xlUp).Row
iRowF1 = Cells.Find(what:="A COMMANDER", lookat:=xlWhole).Row - 2
iRowF2 = Range("F" & Rows.Count).End(xlUp).Row
iTRow = Target.Row
iCRow = Target.Column
'
If Not Intersect(Target, Union(Range("C13:C" & iRowA), Range("H13:H" & iRowF), Range("M13:M" & iRowK))) Is Nothing Then
iRow = Range("F" & iRowF1 + 2 & ":F" & iRowF2).Find(what:=Target.Offset(0, -2), lookat:=xlWhole).Row
Select Case Target
Case "", 0
If iRow > 0 Then Range("F" & iRow & ":H" & iRow).Delete shift:=xlUp
Case Is > 0
If iRow = "" Then iRow = iRowF2 + 1
Range("H" & iRow).Value = Target
Range("F" & iRow).Value = Target.Offset(0, -2)
End Select
Range("F" & iRowF1 + 3 & ":H" & Range("F" & Rows.Count).End(xlUp).Row).Borders.LineStyle = xlContinuous
Range("F" & iRowF1 + 2 & ":H" & Range("F" & Rows.Count).End(xlUp).Row).BorderAround Weight:=xlMedium
End If
'
On Error GoTo 0
Application.EnableEvents = True
'
End Sub
A+
Ooops, oublié de joindre le fichier...