Home » excel » contextmenu – Revised Excel "cell" context menu doesn't work in table

contextmenu – Revised Excel "cell" context menu doesn't work in table

Posted by: admin April 23, 2020 Leave a comment

Questions:

I created a new item for the right click context menu in Excel. It doesn’t appear in my right click context menu when I right click on a cell in a table. Otherwise it does appear. The code that I used (copied from the web) is:

Sub AddItemToContextMenu()
  Dim cmdNew As CommandBarButton
  Set cmdNew = CommandBars("cell").Controls.Add

  With cmdNew
    .Caption = "Copy Occurence Across"
    .OnAction = "CopyOccurrence"
    .BeginGroup = True
  End With
End Sub

Is there something I can do to make my new item appear when clicking on a cell that’s in a table?

How to&Answers:

To add a control to the right-click context menu of a table item, you need to reference the “List Range Popup” context menu.

CommandBars("List Range Popup").Controls.Add

See the following post: Custom excel right click context menu gets overwritten by Quick Analysis defaults