Right Click a Cell

Duncan Butterworth

New Member
Joined
Jul 12, 2006
Messages
43
Hi,
When I right click on a cell I get a drop down menu and a box containing tools above or blow it, I would like to customize this box of tools and the drop down menu also, is this possible.
Thanking you in advance.
Regards,
Duncan.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hey,

It is definitely possible, take a look at CommandBar, CommandBarButton, Application.CommandBars - i'm not too familiar with how to set it up but I know you can add macro's to the cell shortcut menu (right click menu) and implement them with open/close workbook events with add-ins etc, as I use one for indexing through the worksheets in the active workbook

Try this as a test:

Code:
Sub MessageBox()
    MsgBox Application.UserName
End Sub


Sub AddToCellShortcutMenu()
    Dim Bar As CommandBar
    Dim NewControl As CommandBarButton
    DeleteFromShortcut
    Set Bar = Application.CommandBars("Cell")
    Set NewControl = Bar.Controls.Add _
        (Type:=msoControlButton, ID:=2, _
        temporary:=True)
    With NewControl
        .Caption = "&My Message Box"
        .OnAction = "MessageBox"
        .Style = msoButtonIconAndCaption
    End With
End Sub


Sub DeleteFromShortcut()
    On Error Resume Next
    Application.CommandBars("Cell").Controls("&MessageBox").Delete
End Sub
 
Last edited:
Upvote 0
Apologies - the last line on the DeleteFromShortcut sub should be "&My Message Box" instead of "&MessageBox" - it must match the caption from the AddToCellShortcutMenu procedure.
 
Upvote 0

Forum statistics

Threads
1,214,996
Messages
6,122,636
Members
449,092
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top