We help IT Professionals succeed at work.

Prevent right click on slicers

Hi,

How do I prevent right click on my slicers in one worksheet?
Comment
Watch Question

Hi

Is that what you are looking for?
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub

Open in new window


If you want to tell them that they cannot right click:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
 Cancel = True
 MsgBox "Right click not accepted on this sheet"
End Sub

Open in new window

Author

Commented:
Hi Jean ,

It's not working on the slicers. It works on other cells though, but not what I need
Sorry.

Besides putting a password to protect your sheet, i cannot see another way to lock right click on slicer.

Let's see if somebody else comeback with another idea.
Top Expert 2010

Commented:
The short answer is, you can't.

There are no Slicer events exposed in VBA.  Theoretically you could use the worksheet events capturing the update of a PivotTable, but by then whatever the user did via right-click has already happened.
Marcell999
then i don't think there is much to do. Sorry.
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.