Disable right-click for multiple worksheets

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,252
This code will prevents users from right-clicking ON THE TAB itself:


Code:
Application.CommandBars("Ply").Enabled = False


but it only works if the user tries to right-click a SINGLE tab.


If they select more than one tab and right-click, they are still able to do so.


Is there some code that prevents users selecting multiple tabs and right-clicking?


Thanks
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,483
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
What version of Excel are you using? There is only one Ply menu as far as I know and it's the same one shown in both situations. Certainly in 2010 disabling it prevents it popping up in either scenario.
 

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,252
I'm using Excel 2010.

Assume I have three worksheets in my workbook.

I am currently on Sheet1. I left-click on the Sheet2 tab, then holding down the Ctrl key, I also left-click on the Sheet3 tab, so now both Sheet2 and Sheet3 are selected.

I then right-click on either tab. I agree the menu does not pop up.

However, I have a Worksheet_Activate event on both Sheet2 and Sheet3 and it gets activated, which I don't want.
 
Last edited:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,483
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
However, I have a Worksheet_Activate event on both Sheet2 and Sheet3 and it gets activated, which I don't want.

That has nothing at all to do with the subject of your thread as far as I can see. Clicking on Sheet2 activates it and therefore the activate event will fire. The only way around that is to disable events.
 

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,252
That has nothing at all to do with the subject of your thread as far as I can see. Clicking on Sheet2 activates it and therefore the activate event will fire. The only way around that is to disable events.

Sorry, I realised afterwards.

FYI, this is my workaround for my problem is disabling the Activate event.

I added this in the Worksheet_Activate event:

Code:
    If ActiveWindow.SelectedSheets.Count = 1 Then
 

Watch MrExcel Video

Forum statistics

Threads
1,108,490
Messages
5,523,251
Members
409,506
Latest member
reneekeane

This Week's Hot Topics

Top