Context Menu in Excel (All Things to Know)

In this article, you will learn 2 ways to get the context menu in Excel. Further, we will explore how to add and remove commands with VBA from the right-click menu. Finally, we will fix the issues when context menu options do not appear in Excel.

Context Menu provides easy and quick access to loaded commands to a selected cell or range. You can also add the most frequently used options in the context menu. By simply right-clicking, you can quickly access your favorite options and save valuable time.

Unfortunately, customizing the Excel context menu is not the same way as modifying the ribbon bar with Customize the Ribbon option. Read the full article to learn all about the right-click menu in Excel. Before that, have a look at the overview image of this article.

Overview of context menu in Excel


Download Practice Workbook

You can download the practice workbook for free.


What Is Context Menu in Excel?

A context menu is a pop-up menu that offers shortcuts users may need to perform.

In a Windows environment, the context menu is accessed by right-clicking with a mouse. For instance, the context menu in Excel displays the shortcuts like Filter, Delete, Paste Special, and other commonly used commands. Here is a list of the most frequently used options in the context menu:

  • Copy: To copy the selected cells or range.
  • Cut: It displays a dotted line around the selected cells and cuts them.
  • Paste Special: It opens the Paste Special dialog.
  • Format Cells: To format the selected cell as a number, text, date, or time data.
  • Delete: To delete cell data.
  • Filter: To get filter by options.

How to Get Context Menu in Excel

Method 1: Right Click to Display Context Menu

Example 1: Cell Context Menu

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

Right-clicking to get cell context menu in Excel


Example 2: Sheet Tab Context Menu

Right-click the Sheet name to get the Sheet Tab context menu.

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


Example 3: Quick Access Toolbar Context Menu

Simply 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 >> right-click on it. Subsequently, the Ribbon bar context menu appears.

Ribbon bar context menu after right-clicking on Ribbon bar


Method 2: Use Shortcut Keys to Show Context Menu

Press Shift + F10 keys as an alternative to get the cell context menu.

Shortcut keys for context menu in Excel


How to Add (and Remove) Custom Button to Context Menu in Excel

To add a custom button in the context menu, go to the Developer tab >> click on Visual Basic.

Visual Basic in Developer tab

In the Visual Basic window, tap on Insert >> Module to create a module box >> enter the below VBA code in the module box >> 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

Thus, we get a custom button named Clear Cell that deletes the selected D5 cell data.

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 Right-Click Menu (Context Menu) Gets Missing in Excel

If the context menu options do not appear due to opening up the file with code or other reasons, fix it with VBA. Go to View in the Visual Basic window >> click Immediate Window.

Immediate Window in View tab

In the Immediate Window, write the following VBA code and press Enter.

Application.CommandBars("Cell").Reset
			

VBA code in Immediate Window


Things to Remember

  • You can update the .Caption and .On Action property 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, you can customize the context menu using the VBA code shown 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.


Conclusion

In conclusion, we have learned 2 easy methods to get context menu in Excel. Later, we added a custom button in the context menu and showed how to remove it with VBA in Excel. We have also fixed context menu issues using VBA code in the Immediate window. Hopefully, you can create your own custom context menu in Excel. Let us know if you have any suggestions or queries in the comment box. For similar articles, visit our ExcelDemy website.


<< 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