1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim I As Long
Dim J As Integer
Dim Feuille As String
'seulement en colonne A
If Target.Column <> 1 Then Exit Sub
'couleur rouge ou bleu
If Target.Interior.ColorIndex = 3 Or Target.Interior.ColorIndex = 41 Then
'décalage par rapport à la ligne noire (insertion en dessus ou en dessous)
J = IIf(Target.Interior.ColorIndex = 3, 1, 0)
'défini la feuille cible
Feuille = IIf(Right(Target.Offset(, 1).Value, 1) = "F", "INSTALLATION", "LIVRAISON")
With Worksheets(Feuille)
'parcour la colonne A à la recherche de la ligne noire
For I = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
'si trouvée
If .Cells(I, 1).Interior.ColorIndex = 1 Then
'insère une ligne au dessous et y colle la ligne choisie
.Cells(I + J, 1).EntireRow.Insert
Target.EntireRow.Copy .Cells(I + J, 1)
Exit For
End If
Next I
End With
End If
Cancel = True 'évite d'entrer en édition dans la cellule
End Sub |
Partager