Some times for some security reason or some other reason, you want to disable right click on the Workbook or Worksheet or on a particular Cell or Cell Range.

1. Disable Right Click on Whole Workbook

Steps:

1. Open Visual Basic Editor (Alt + F11)
2. Double Click on Highlighted part in below Image
3. Copy and Paste the below Code and you are done 🙂 🙂

How to Disable Right Click

How to Disable Right Click

Private Sub Workbook_SheetBeforeRightClick _
(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox ("Sorry Right Click is Disbaled for this Workbook")
End Sub

 

2. Disable Right Click on WorkSheet

Steps:

1. Open Visual Basic Editor (Alt + F11)
2. Double Click on Highlighted part in below Image (On the Sheet where you want to Disable Right Click)
3. Copy and Paste the below Code and you are done 🙂 🙂
4. Change the Cell Range in the below Code as per your requirement and Enjoy 🙂 🙂

 

Disable Right Click on Cell Range

Disable Right Click on WorkSheet

 

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox ("Sorry Right Click is Disbaled for this Workbook")
End Sub

 

3. Disable Right Click on a Cell or Cell Range

Steps:

1. Open Visual Basic Editor (Alt + F11)
2. Double Click on Highlighted part in below Image (On the Sheet where the Cell Range exist where you want to Disable Right Click)
3. Copy and Paste the below Code and you are done 🙂 🙂
4. Change the Cell Range in the below Code as per your requirement and Enjoy 🙂 🙂

 

Disable Right Click on Cell Range

Disable Right Click on WorkSheet

 

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
 If Target = "A1" Then
  Cancel = True
 End If
End Sub