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?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,736
Members
448,988
Latest member
BB_Unlv

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
Back
Top