Il y une solution en utilisant le fonction before click
Private Sub Worksheet_beforeRightClick(ByVal Target As Range, Cancel As Boolean) Range("C3").Select With Selection.Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:="=$C$4:$C$6" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub
Cela peu déjà t'aider, à toi de la changer selon tes souhaits.
Cordialement.
Rémi.
-----Message d'origine----- salut,
Je voudrait créer une macro qui fasse apparaitre un menu en cliquant sur le bouton droit de la souris, comment faut-il faire ? .
ced
merci
-----Message d'origine----- Salut ced,
Une idée à adapter selon tes besoins. 2 boutons et un combo sont créés.
--------A mettre dans un module standard : Private Sub MenuPopup() Dim Barre As CommandBar Dim Btn As CommandBarButton Dim Cmb As CommandBarComboBox Dim I As Integer On Error Resume Next CommandBars("MaBarre").Delete On Error GoTo 0 Set Barre = CommandBars.Add("MaBarre", msoBarPopup) With Barre Set Btn = .Controls.Add(msoControlButton) With Btn .OnAction = "Macro1" .Caption = "Macro 1" .FaceId = 3648 End With Set Btn = .Controls.Add(msoControlButton) With Btn .OnAction = "Macro2" .Caption = "Macro 2" .FaceId = 3650 End With Set Cmb = .Controls.Add(msoControlComboBox) With Cmb For I = 1 To 7 .AddItem WeekdayName(I) Next I .OnAction = "MacroCombo" .BeginGroup = True End With End With Set Barre = Nothing Set Btn = Nothing Set Cmb = Nothing End Sub
Sub MacroCombo() With CommandBars.ActionControl MsgBox (.List(.ListIndex)) End With End Sub
Sub Macro2() MsgBox "Macro 2" End Sub
Sub Macro1() MsgBox "Macro 1" End Sub
---------A mettre dans le module de ta feuille et à adapter :
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean) If Target.Address(0, 0) = "A1" Then CommandBars("MaBarre").ShowPopup Cancel = True End If End Sub
Hervé.
"ced" a écrit dans le message news:
0b3901c351e8$bcb16230$ salut,
Je voudrait créer une macro qui fasse apparaitre un menu en cliquant sur le bouton droit de la souris, comment faut-il faire ?
.
merci
-----Message d'origine-----
Salut ced,
Une idée à adapter selon tes besoins. 2 boutons et un
combo sont créés.
--------A mettre dans un module standard :
Private Sub MenuPopup()
Dim Barre As CommandBar
Dim Btn As CommandBarButton
Dim Cmb As CommandBarComboBox
Dim I As Integer
On Error Resume Next
CommandBars("MaBarre").Delete
On Error GoTo 0
Set Barre = CommandBars.Add("MaBarre", msoBarPopup)
With Barre
Set Btn = .Controls.Add(msoControlButton)
With Btn
.OnAction = "Macro1"
.Caption = "Macro 1"
.FaceId = 3648
End With
Set Btn = .Controls.Add(msoControlButton)
With Btn
.OnAction = "Macro2"
.Caption = "Macro 2"
.FaceId = 3650
End With
Set Cmb = .Controls.Add(msoControlComboBox)
With Cmb
For I = 1 To 7
.AddItem WeekdayName(I)
Next I
.OnAction = "MacroCombo"
.BeginGroup = True
End With
End With
Set Barre = Nothing
Set Btn = Nothing
Set Cmb = Nothing
End Sub
Sub MacroCombo()
With CommandBars.ActionControl
MsgBox (.List(.ListIndex))
End With
End Sub
Sub Macro2()
MsgBox "Macro 2"
End Sub
Sub Macro1()
MsgBox "Macro 1"
End Sub
---------A mettre dans le module de ta feuille et à
adapter :
Private Sub Worksheet_BeforeRightClick(ByVal Target As
Range, _
Cancel As Boolean)
If Target.Address(0, 0) = "A1" Then
CommandBars("MaBarre").ShowPopup
Cancel = True
End If
End Sub
Hervé.
"ced" <cmarmonier@ifotec.com> a écrit dans le message
news:
0b3901c351e8$bcb16230$a501280a@phx.gbl...
salut,
Je voudrait créer une macro qui fasse apparaitre un menu
en cliquant sur le bouton droit de la souris, comment
faut-il faire ?
Une idée à adapter selon tes besoins. 2 boutons et un combo sont créés.
--------A mettre dans un module standard : Private Sub MenuPopup() Dim Barre As CommandBar Dim Btn As CommandBarButton Dim Cmb As CommandBarComboBox Dim I As Integer On Error Resume Next CommandBars("MaBarre").Delete On Error GoTo 0 Set Barre = CommandBars.Add("MaBarre", msoBarPopup) With Barre Set Btn = .Controls.Add(msoControlButton) With Btn .OnAction = "Macro1" .Caption = "Macro 1" .FaceId = 3648 End With Set Btn = .Controls.Add(msoControlButton) With Btn .OnAction = "Macro2" .Caption = "Macro 2" .FaceId = 3650 End With Set Cmb = .Controls.Add(msoControlComboBox) With Cmb For I = 1 To 7 .AddItem WeekdayName(I) Next I .OnAction = "MacroCombo" .BeginGroup = True End With End With Set Barre = Nothing Set Btn = Nothing Set Cmb = Nothing End Sub
Sub MacroCombo() With CommandBars.ActionControl MsgBox (.List(.ListIndex)) End With End Sub
Sub Macro2() MsgBox "Macro 2" End Sub
Sub Macro1() MsgBox "Macro 1" End Sub
---------A mettre dans le module de ta feuille et à adapter :
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean) If Target.Address(0, 0) = "A1" Then CommandBars("MaBarre").ShowPopup Cancel = True End If End Sub
Hervé.
"ced" a écrit dans le message news:
0b3901c351e8$bcb16230$ salut,
Je voudrait créer une macro qui fasse apparaitre un menu en cliquant sur le bouton droit de la souris, comment faut-il faire ?