Suppress warning message

ElvisSteel

Board Regular
Joined
Mar 23, 2009
Messages
122
Hi,

I have a sheet on which I want the user to double click on a cell in order to trigger some code. I don't want the cell to be edited, so the cell is locked. When I double click on it, the code triggers OK, but I get the message:

"The cell or chart you are trying to change is protected...."

Is it possible to stop this message from appearing, I have tried setting Application.DisplayAlerts = False but this doesn't seem to work.

On a similar point, can the standard right-click menu also be disabled? (the one with Cut, Copy, Paste .... Hyperlink etc)

Thanks

Steve
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hello Steve

You can prevent a user from editing a cell with:
Code:
[COLOR=blue]Private[/COLOR] [COLOR=blue]Sub[/COLOR] Worksheet_BeforeDoubleClick([COLOR=blue]ByVal[/COLOR] Target [COLOR=blue]As[/COLOR] Range, Cancel [COLOR=blue]As[/COLOR] [COLOR=blue]Boolean[/COLOR])
    Cancel = [COLOR=blue]True[/COLOR]
[COLOR=blue]End[/COLOR] [COLOR=blue]Sub[/COLOR]
The message won't appear.

And the following to prevent right-click menu:
Code:
[COLOR="Blue"]Private[/COLOR] [COLOR="Blue"]Sub[/COLOR] Worksheet_BeforeRightClick([COLOR="Blue"]ByVal[/COLOR] Target [COLOR="Blue"]As[/COLOR] Range, Cancel [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Boolean[/COLOR])
    Cancel = [COLOR="Blue"]True[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
Thanks very much Jon,

I knew about "Cancel = True" but didn't think of using it after executing some code.

Works perfectly! :)
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

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