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

ย 

cover3d_0-89071700_1484285537__1_

Join over 10, 000+ Excel VBA Enthusiasts & get this FREE e-Book Now!