Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim First As Boolean
If Not Application.Intersect(Target, [Tadhere[Nom adhérent]]) Is Nothing Then
If IsToolBar("ClicDroit") Then CommandBars("ClicDroit").Delete
With CommandBars.Add(Name:="ClicDroit", Position:=msoBarPopup, Temporary:=True)
With .Controls.Add(msoControlButton, 1, , , True)
.Caption = "Désactiver pour cause de :"
.FaceId = 326
End With
First = True
For Each Raison In [Tableau1[Raisons]]
If Not IsEmpty(Raison) Then
With .Controls.Add(msoControlButton, 1, , , True)
.Caption = Raison
.OnAction = "'" & Me.CodeName & ".Désactiver_Membre " & _
"""" & Target.Address & """,""" & Raison & """'"
If First Then
First = False
.BeginGroup = True
End If
End With
End If
Next
.ShowPopup
.Delete
End With
Cancel = True
End If
End Sub
Sub Désactiver_Membre(Target As String, Raison As String)
Dim Décalage As Long
Décalage = [Tadhere[Actif]].Column - [Tadhere[Nom adhérent]].Column
With Me.Range(Target).Offset(0, Décalage)
' .Activate
.Value = "N"
End With
Décalage = [Tadhere[Raison]].Column - [Tadhere[Nom adhérent]].Column
With Me.Range(Target).Offset(0, Décalage)
.Activate
.Value = Raison
End With
End Sub
Function IsToolBar(Barre As String) As Boolean
IsToolBar = False
For Each Elem In Application.CommandBars
If Elem.Name = Barre Then
IsToolBar = True
Exit For
End If
Next
End Function