Customizing Right-Click Context Menu In Excel For CommandBars Cell Row And Column
I have compiled a set of macros and user forms (lets call them extras) and I have managed to place them in the context menu of the cell.
I have used the logic described in this article. Check the code of AddToCellMenu and DeleteFromCellMenu Subs.
It worked on one or more cells perfectly, however I realized that when I right clicked a row or column the context menu did not have the extras.
It applied on one or more cells cause I have used
Code:
Dim ContextMenu As CommandBar
Set ContextMenu = Application.CommandBars("Cell")
but in order to make it work for rows context menu I have to use
Code:
Dim ContextMenu As CommandBar
Set ContextMenu = Application.CommandBars("Rows")
and for columns context menu use
Code:
Dim ContextMenu As CommandBar
Set ContextMenu = Application.CommandBars("Columns")
I would like to combine them somehow so as not to repeat unnecessarily lines of code for each context menu so as to apply the extras, especially if you think that they are in several submenus also...
Please advise... and thank you in advance for any idea.