Wednesday, April 15, 2009

Macros in Excel : Disable Right Click Menu

Many times we need to disable right click menu in our workbook. We can achieve this by using Marcos in Excel. You need to add the Macro code to This workbook section in your VBA project. When you go to your Visual Basic Editor you can see the ThisWorkbook on the left hand side of your VBA Project.

You need to double click on highlighed portion and copy the following code. Since these macros has Private word before Sub, no one will be able to see this macros from View Macro menu.
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox "Right click menu deactivated." & vbCrLf & _
"For this file:", 16, ""
End Sub


  1. Very techie blog on Excel and I have surprised to see so many thing on Excel , It's looks like a Programming in Excel rather than saying Tips on Excel.
    Yogesh - Great job done by you, Best wishes for your future.

  2. Nice work Yogesh

  3. Hi, Is there anyone who can help me out?. I have disabled the move or copy sheet option on right click(sheet tab). Now i want to disable the Move or copy sheet option from home menu(home->format->Move or copy sheet).It drives me crazy?. Thanks in advance.