Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo Fin
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
If Target.Interior.Color = vbWhite And Cells(Target.Row - 2, "B") <> 0 Then
Ligne = Target.Row
Target.Interior.Color = vbRed
Application.ScreenUpdating = False
Application.EnableEvents = False
If MsgBox("Voulez vous inserer des lignes ?", vbYesNo, "Insertion request") = vbYes Then
Target.Interior.Color = vbWhite
Rows(Target.Row & ":" & Target.Row).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
' Copier coller lignes à la fin
Range(Target.Row - 8 & ":" & Target.Row - 4).Copy Destination:=Range("A" & Target.Row - 4)
' Clear Cells A:B dernière ligne
Range(Cells(Target.Row - 2, "A"), Cells(Target.Row - 1, "B")).ClearContents
' Fait la même modif dans toutes les feuilles
InsertionDansToutesLesFeuilles Ligne
Else
Target.Interior.Color = vbWhite
Application.EnableEvents = True
Exit Sub
End If
Cells(Target.Row - 4, "A").Select
End If
End If
Fin:
Application.EnableEvents = True
End Sub