Hello everyone,
So I have a macro called Duplication I wrote and I want to add it from the right click menu with the caption Dupliquer.
I have found this code which allows it when I right click on a cell :
So this code indeed adds a Dupliquer option in the menu when I right click. It works so well it even adds it every time I right click though ! Meaning after 3 right clicks I have the new option thrice in my menu, which wasn't excactly what I was hoping for...
But my biggest problem is that this only works for a right click on a single cell and my macro is supposed to work on a range of cells. I naively tried turning every "Cell" into "Range" (I am new to VBA) but of course it did not work.
Any idea ?
Any tip would be greatly appreciated !
Thank you for reading,
Marie
So I have a macro called Duplication I wrote and I want to add it from the right click menu with the caption Dupliquer.
I have found this code which allows it when I right click on a cell :
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub Workbook_Deactivate()
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Duplication").Delete
End With
On Error GoTo 0
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif] Dim cmdBtn As CommandBarButton
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Duplication").Delete
Set cmdBtn = .CommandBars("Cell").Controls.Add(Temporary:=True)
End With
With cmdBtn
.Caption = "Dupliquer"
.Style = msoButtonCaption
.OnAction = "Duplication"
End With
On Error GoTo 0
End Sub
[/FONT]
So this code indeed adds a Dupliquer option in the menu when I right click. It works so well it even adds it every time I right click though ! Meaning after 3 right clicks I have the new option thrice in my menu, which wasn't excactly what I was hoping for...
But my biggest problem is that this only works for a right click on a single cell and my macro is supposed to work on a range of cells. I naively tried turning every "Cell" into "Range" (I am new to VBA) but of course it did not work.
Any idea ?
Any tip would be greatly appreciated !
Thank you for reading,
Marie