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
- 2. Disable Right Click on whole WorkSheet
- 3. Disable Right Click on a 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 🙂 🙂
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 🙂 🙂
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 🙂 🙂
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target = "A1" Then
Cancel = True
End If
End Sub
I have forgot my protect workbook password. Is there a way to reset the protect workbook password (in excel) or using any vba code?
Is there a way to hide modules using vba codes like Modules("Screen Management").Visible = xlVeryHidden?
Is this allowed?
No, you can not hide a module in excel VBA. you can protect the whole code of a workbook but not a single module.
CTRL+C and CTRL+V is still working.