Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
'MsgBox Target.Interior.ColorIndex
If Target.Column = 4 And Target.Interior.ColorIndex = 6 Then 'colonne D sur une cellule jaune...
'on cherche la position du tableau dans la feuille données
With Sheets("Données").Range("B:B")
'MsgBox Target.Item(1)
Set c = .Find(Target.Item(1)) ', LookIn:=xlValues, XlLookAt:=xlWhole)
If Not c Is Nothing And c.Value <> "" Then 'si il y a une valeur..
'recopie du tableau
.Range("B" & c.Row - 1 & ":G" & c.Row + 2).Copy Destination:=Target.Offset(-1, 1) 'va comprendre pourquoi il faut mettre B alors que le tableau commence en C......?????
Else
Target.Offset(-1, 1).Resize(4, 5).ClearContents 'si numéro pas trouvé: on efface
End If
End With
End If
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Count = 1 And Target.Column = 3 Then
If LCase(Target.Value) = "ajouter" Then
'ligne active
maligne = Target.Row
Rows(maligne + 2 & ":" & maligne + 7).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A" & maligne + 8 & ":I" & maligne + 13).Copy Destination:=Range("A" & maligne + 2)
'décale sélection d'une ligne
Range(Target.Address).Offset(1, 0).Select
End If
End If
Application.EnableEvents = True
End Sub