VBA & Macro Problems

How to Disable Excel Comments from Right-Click Menu Using VBA

Algirdas JasaitisAlgirdas Jasaitis Nov 2, 2026 869 views

Question details

The user wants to prevent individuals from modifying workbook comments by removing or disabling the Insert, Edit, Delete, and Show/Hide Comment options from the right-click context menu.

How to Disable Excel Comments from Right-Click Menu Using VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
Restricting users from managing cell comments via the right-click shortcut menu to maintain standardized workbook formatting and prevent unauthorized annotations.
Observed behavior
By default, users can freely right-click any cell in Excel to interact with comments. The goal is to make these specific commands inactive or hidden in the context menu.
Before you start

Ensure that the Developer tab is enabled in your application's ribbon to access the VBA editor, and remember to save your file as a Macro-Enabled Workbook (.xlsm) so the code remains active.

Solution 1Recommended

Use a VBA Macro to Disable Right-Click Comment Commands

Run a simple VBA script targeting the "Cell" command bar to disable all comment-related menu controls.

This approach uses the Application.CommandBars property to directly target the default right-click context menu for standard cells. By setting the Enabled property of comment-specific controls to False, users will no longer be able to click them.

1
Open the VBA Editor

Launch your workbook and press the Alt + F11 keys simultaneously to open the Visual Basic for Applications (VBA) window.

2
Insert a Standard Module

In the VBA editor, navigate to the top menu and click Insert, then select Module to create a blank coding space.

3
Paste the VBA Code

Copy and paste the following code into the new module window: Sub Disable_Comments() On Error Resume Next With Application.CommandBars("Cell") .Controls("Insert Comment").Enabled = False .Controls("Delete Comment").Enabled = False .Controls("Edit Comment").Enabled = False .Controls("Show/Hide Comments").Enabled = False End With End Sub

4
Run the Macro

Click inside the code and press F5, or select Run > Run Sub/UserForm from the top menu. Return to your worksheet and right-click any cell to verify the comment options are disabled.

Important Limitation: This macro only disables the commands inside the right-click menu. Users can still insert, edit, or delete comments by navigating to the Review tab on the main ribbon unless you also apply workbook protection.
Advanced Spreadsheet Automation

Manage VBA Macros seamlessly in WPS Office

WPS Spreadsheet provides excellent support for VBA macros, allowing you to easily customize command bars, automate repetitive tasks, and fully protect your workbooks without performance lags.

  1. 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and complete the installation process.
  2. 2. Open the Macro-Enabled File: Launch WPS Spreadsheet and open your existing .xlsm or .xlsb workbook.
  3. 3. Run VBA Scripts via the Developer Tab: Navigate to the Developer tab on the ribbon, open the VBA Editor, and run or manage your macros seamlessly.
Fully compatible with Microsoft Excel VBA macros, .xlsm, and .xlsb formats.Built-in Developer tools for writing and debugging scripts seamlessly.Comprehensive workbook and worksheet protection features.Lightweight application with a highly intuitive user interface.
microsoft office alternative - wps office

Frequently Asked Questions

How do I re-enable the right-click comment options later?

You can restore the right-click comment functions by running a similar VBA macro, but changing '.Enabled = False' to '.Enabled = True' for each of the respective controls.

Does this macro prevent comments from being added via the Review tab?

No, this specific macro only targets the cell right-click (context) menu. To completely prevent comment modifications across the entire application, you must apply 'Protect Sheet' and ensure the 'Edit objects' option remains unchecked.

Why did the macro stop working when I reopened the file?

This happens if you saved the file as a standard Excel Workbook (.xlsx) which strips out VBA code, or if your macro security settings disable macros by default upon opening. Always save as a Macro-Enabled Workbook (.xlsm) and click 'Enable Content' when prompted.