Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Select Case True
Case Not Application.Intersect(Target, [Tab_Fertilisation[#Headers]]) Is Nothing
Case Application.Intersect(Target, [Tab_FERTILISATION[#Data]]) Is Nothing
Case Else
Cancel = True 'empêche l'affichage du menu d'Excel
With Application.CommandBars("Cell")
With .Controls.Add(msoControlButton, 1, , 1, True)
.Caption = "Supprimer la ligne de Table"
.FaceId = 1088
.OnAction = Me.CodeName & ".Sup_Tab"
End With
With .Controls.Add(msoControlButton, 1, , 1, True)
.Caption = "Ajouter une ligne de Table içi"
.FaceId = 1142
.OnAction = Me.CodeName & ".Add_Tab"
End With
With .Controls.Add(msoControlButton, 1, , 1, True)
.Caption = "Ajouter une ligne en fin de Table"
.FaceId = 1145
.OnAction = "'" & Me.CodeName & ".Add_Tab ""True""'"
.BeginGroup = True
End With
.ShowPopup
For Each Control In .Controls
If Not Control.BuiltIn Then Control.Delete
Next
End With
End Select
End Sub
Sub Sup_Tab()
Frow = Selection.Row
Trow = [Tab_FERTILISATION[#Data]].Row
Me.Unprotect
Application.EnableEvents = False
[Tab_FERTILISATION].Rows(Frow - Trow + 1).Delete
Application.EnableEvents = True
Me.Protect
End Sub
Sub Add_Tab(Optional En_Fin As Boolean)
Frow = Selection.Row
Trow = [Tab_FERTILISATION[#Data]].Row
Me.Unprotect
Application.EnableEvents = False
If En_Fin Then
[Tab_FERTILISATION].ListObject.ListRows.Add
Else
[Tab_FERTILISATION].ListObject.ListRows.Add Frow - Trow + 1
End If
Application.EnableEvents = True
Me.Protect
End Sub