Context Menu in Excel (All Things to Know)

In this article, we will discuss the context menu (or right-click menu) in Excel, including 2 ways to open the context menu, how to add and remove commands with VBA, and how to fix the issues when context menu options do not appear.

Overview of context menu in Excel


Download Practice Workbook


What Is the Context Menu in Excel?

The context menu is a pop-up menu that offers shortcuts to commonly used Excel commands and features.

In a Windows environment, the context menu is accessed by right-clicking with the mouse. It displays commonly used commands such as:

  • Copy: Copies the selected cells or range.
  • Cut: Displays a dotted line around the selected cells and cuts them.
  • Paste Special: Opens the Paste Special dialog.
  • Format Cells: Formats the selected cell as a number, text, date, or time data.
  • Delete: Deletes cell data.
  • Filter: Opens Filter By options.

How to Open the Context Menu in Excel

Method 1 – Right Clicking to Display the Context Menu

Example 1 – Cell Context Menu

Right-click on cell D5 to display the Cell context menu.

Right-clicking to get cell context menu in Excel


Example 2 – Sheet Tab Context Menu

Right-click a sheet name to open the Sheet Tab context menu.

Right-clicking on Sheet name for Sheet tab context menu in Excel


Example 3 – Quick Access Toolbar Context Menu

Right-click on the Quick Access Toolbar to show its context menu options.

Quick Access Tool context menu


Example 4 – Ribbon Bar Context Menu

Go to the Ribbon bar and right-click on it to open its context menu.

Ribbon bar context menu after right-clicking on Ribbon bar


Method 2 – Using Shortcut Keys to Show the Context Menu

Press Shift + F10 to open the Cell context menu.

Shortcut keys for context menu in Excel


How to Add (and Remove) Custom Options to the Context Menu

To add a custom button to the context menu:

  • Go to the Developer tab and click on Visual Basic.

Visual Basic in Developer tab

  • In the Visual Basic window, click on Insert >> Module to create a module box.
  • Enter the below VBA code in the module box.
  • Click Run to execute the code.
Sub AddContextMenuDeleteItem()
    Dim cBar As CommandBar
    Dim cBarCtrl As CommandBarControl
    Set cBar = Application.CommandBars("Cell")
    Set cBarCtrl = cBar.Controls.Add(Type:=msoControlButton)
    With cBarCtrl
        .Caption = "Clear Cell"
        .OnAction = "DeleteCellContent"
    End With
End Sub
Sub DeleteCellContent()
    Selection.ClearContents
End Sub
			

VBA code in module box

In the Cell context menu, we now have a custom option named Clear Cell that deletes the data in the selected D5.

Custom button in context menu in Excel

  • To remove the custom button, run the below VBA code in the same way.
Sub Remove_Items_from_Context_Menu()
   On Error Resume Next
   CommandBars("cell").Controls("Clear Cell").Delete
End Sub
			

Removing custom button


How to Fix When the Context Menu Goes Missing in Excel

If the context menu options do not appear due to opening up the file with code or for other reasons, we can fix it with VBA as follows;.

  • Go to View in the Visual Basic window and click Immediate Window.

Immediate Window in View tab

  • In the Immediate Window, enter the following VBA code and press Enter:
Application.CommandBars("Cell").Reset
			

VBA code in Immediate Window


Things to Remember

  • Update the .Caption and .On Action properties in the VBA code to change the name of the custom button in the context menu.
  • Customizing the Context Menu is not done in the same way as customizing the Ribbon bar in Excel.

Frequently Asked Questions

  • Is it possible to change the order of the options in the Context menu?

No, the order of options in the Context menu is predefined and cannot be directly modified. However, we can customize the context menu using the VBA code provided above and arrange the options in the desired order.

  • What is the difference between the context menu and the shortcut menu?

The context menu and the shortcut menu are both pop-up menus that appear when you right-click on a cell or object in Excel. However, the context menu contains a wider variety of commands and functions, while the shortcut menu only contains the most commonly used commands.


<< Go Back to Excel Parts | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Yousuf Khan
Yousuf Khan

Yousuf Khan has been working with the ExcelDemy project for over one year. He has written 47+ articles for the ExcelDemy site. He also solved a lot of user problems with ExcelDemy Forum. He has interests in Excel & VBA, Desktop and mobile applications, and projects & templates. He completed his graduation and post-graduation in Information Technology from Jahangirnagar University. Currently, he works as a VBA & Excel Content Developer in ExcelDemy projects, writing unique and informative content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo