Right Click problem on protected sheet

ElsiePOA

New Member
Joined
Oct 27, 2011
Messages
4
I have a macro which puts a check mark in any cell in column A if I right click on the cell. My problem is that when I protect the sheet, although a right click still puts a check mark in the cell, it also opens the right click context menu which is annoying. Is there a way to correct this short of just leaving the worksheet in the unprotected mode?
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

ElsiePOA

New Member
Joined
Oct 27, 2011
Messages
4
Thanks for the response. Unfortunately, cancel=true was already in the macro.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Probably in the wrong place. Please post your code.
 

ElsiePOA

New Member
Joined
Oct 27, 2011
Messages
4

ADVERTISEMENT

Here it is:

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

If Target.Count > 1 Then Exit Sub
If Target.Column = 1 _
Or Target.Column = 6 _
Or Target.Column = 7 _
Or Target.Column = 23 _
Or Target.Column = 27 _
Then
On Error GoTo errHandler:
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Formula = "=char(252)"
Target.Font.Name = "Wingdings"
Target.Font.ColorIndex = 1
Else
Target.ClearContents
End If
Cancel = True
End If
errHandler:
Application.EnableEvents = True
End Sub
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Pervades

Code:
Application.EnableEvents = False
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 _
Or Target.Column = 6 _
Or Target.Column = 7 _
Or Target.Column = 23 _
Or Target.Column = 27 _
Then
On Error GoTo errHandler:
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Formula = "=char(252)"
Target.Font.Name = "Wingdings"
Target.Font.ColorIndex = 1
Else
Target.ClearContents
End If
Cancel = True
End If
errHandler:
Application.EnableEvents = True
End Sub
 

ElsiePOA

New Member
Joined
Oct 27, 2011
Messages
4
Replaced the macro with the one you sent. It works the same way as the previous on. Great on unprotected worksheet, but calls up context menu if sheet is protected. Incidently, I tried it on both my laptop and my desktop. Works the same on both. I don't know if I mentioned it, or if it matters but I'm using Excel 2003 on a windows XL machinr.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,313
Members
414,052
Latest member
Dual Showman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top