ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Worksheet Protection Question (https://www.excelbanter.com/excel-discussion-misc-queries/219129-worksheet-protection-question.html)

Pat

Worksheet Protection Question
 
I have a worksheet where I want to lock cells and unlocked.

After I protect the sheet....

-I want to be able to have users input data in unlocked cells
-I want users to be able to select certain locked cells
-I also want users to NOT be able to select certain locked cells

Is this possible? If yes, how?

Dave Peterson

Worksheet Protection Question
 
The first is the way unlocked cells on protected worksheets behave.

The last two is not.

If you're using xl2002+, you could stop the user from selecting all locked
cells. But that breaks rule #2.

Maybe you could use an event macro that checks the selection and stops the user
from selecting one of those "unselectable" cells.

But if macros or events are disabled, then this won't work.

If you want to try, select all the cells that shouldn't be selected. (It won't
matter if the worksheet is protected and it won't matter if the cells are
locked/unlocked.)

Give that range a nice name. I used "UnSelectable"

Then rightclick on the worksheet tab that should have this behavior and select
view code.

Paste this into the newly opened code window:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Me.Range("unselectable")) Is Nothing Then
'do nothing
Else
'send them somewhere else
Application.EnableEvents = False
Me.Range("a1").Select
Application.EnableEvents = True
End If
End Sub

Then back to excel and test it.

Remember...

if macros or events are disabled, then this won't work.

Pat wrote:

I have a worksheet where I want to lock cells and unlocked.

After I protect the sheet....

-I want to be able to have users input data in unlocked cells
-I want users to be able to select certain locked cells
-I also want users to NOT be able to select certain locked cells

Is this possible? If yes, how?


--

Dave Peterson


All times are GMT +1. The time now is 08:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com