Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    78

    Question Unanswered: Disable right click

    How can I disable right click on an excel sheet? It should display message saying "Command not allowed .."

    Thanks.

    ~BS

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    Try pasting this in the in every worksheet VBA code module that you want it disabled.

    Code:
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)
        MsgBox "Command not allowed.", vbCritical, "Command Disabled"
        Cancel = True
    End Sub

    HTH

    MTB

  3. #3
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi again

    Alterrnatively you could put the code in the ThisWorkbook code module
    ie
    Code:
    Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Excel.Range, Cancel As Boolean)
        MsgBox "Command not allowed.", vbCritical, "Command Disabled"
        Cancel = True
    End Sub
    This will disable all sheets right click.

    MTB

  4. #4
    Join Date
    Dec 2004
    Posts
    78

    Thumbs up

    Thanks Mike. The code works.

    ~BS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •