Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Using VBA to Customize Shortcut Menus
In this section, I present some practical examples of VBA code that manipulates Excel's shortcut menus. These examples give you an idea of the types of things you can do with shortcut menus, and they can all be modified to suit your needs.
Resetting a shortcut menu
The Reset method restores a shortcut menu to its original, default condition. The following procedure resets the Cell shortcut menu to its normal state:
Sub ResetCellMenu()
CommandBars(“Cell”).Reset
End Sub
As I noted earlier, Excel has two shortcut menus named Cell. The preceding code resets only the first one (index of 35). To reset the second Cell shortcut menu, you can use its index number (38) instead of its name. But remember, the index numbers aren't consistent across Excel versions. Here's a better procedure to reset both instances of the Cell shortcut menu: