Unlocked Cell To Allow Mouse Selection (click) Yet Deny Value Editing?

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
OK, here's another "is it possible" question.

I have a protected worksheet set that only unlocked cells can be selected.
With that worksheet, the majority of cells are locked (to prevent the user from clicking all over the place). A few cells and ranges are unlocked. The user is encouraged, and expected to click on these cells.
For the most part, I do not want the user to edit the contents of the unlocked cells (which would suggest I need them locked), however, I want to execute a macro when the user clicks ? double clicks on that unlocked cell.

I haven't tried it yet, maybe the mouseclick (?) event will trigger before allowing the cell to enter editing mode. But if not, is what I want to do doable? ie keep a cell selectable for clicking with the mouse yet preventing the contents from being edited?
 

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.
You can allow selection of protected cells on a protected sheet, but with the cell locked, you cannot edit the cell.
 
Upvote 0
Thank you CountTepes. With experimentation I discovered that clicking on an unlocked cell when Worksheet_BeforeDoubleClick event has been written will execute the code before allowing the user to edit tat cell's contents. I figure in the BeforeDoubleClick code one could lock that cell and carry on executing the code if editing the cell contents isn't permitted. KKeep the cell unlocked only long enough to accept a double click.
 
Upvote 0
Why not use a BeforeRightClick event rather than a DoubleClick event?
 
Upvote 0
Thank you CountTepes. With experimentation I discovered that clicking on an unlocked cell when Worksheet_BeforeDoubleClick event has been written will execute the code before allowing the user to edit tat cell's contents. I figure in the BeforeDoubleClick code one could lock that cell and carry on executing the code if editing the cell contents isn't permitted. KKeep the cell unlocked only long enough to accept a double click.

Have you considered setting the Cancel argument in the Worksheet_BeforeDoubleClick event handler to prevent editing the cell ?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

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