Lock selected cells without protecting worksheet

Folks,
I was wondering if it is possible to lock selected cells without protecting a worksheet? I know how to unlock selected cells while the remaining cells are locked by protecting the worksheet.
Frank FreeseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DephaultCommented:
Right click on the cells and go to the Protection tab and choose whether its locked or not there.

Protecting then enables the lock. But you could Protect the sheet and set a blank password.

OR

You could also detect the change in an event and stop the edit. Maybe expand on your question for this one.
0
Martin LissOlder than dirtCommented:
Or you can simply do something like in this example which "protects" A3 and A5.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Column = 1 Then
        If Target.Row = 3 Or Target.Row = 5 Then
            Beep
           Cells(Target.Row, Target.Column).Offset(0, 1).Select
        End If
    End If
    
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frank FreeseAuthor Commented:
Martin,
Let me make sure I understand your solution. This code would keep me from protecting a worksheet yet protect selected cells from changes?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Martin LissOlder than dirtCommented:
Yes. In my example if the user tries to select A3 or A5, he'll hear a beep and the cursor will move one cell to the right.
0
Frank FreeseAuthor Commented:
thanks Martin - it looks like I can apply this to my model.
0
Frank FreeseAuthor Commented:
great work - I am grateful, as always
0
Martin LissOlder than dirtCommented:
And as always you're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0
DephaultCommented:
So what I said initially didn't count?

'detect the change in an event and stop the edit' is exactly the answer is you got. Dont I deserve some points?
0
Martin LissOlder than dirtCommented:
If fh_freese wants to get moderator support to change his points assignment I don't have a problem.
0
Frank FreeseAuthor Commented:
Dephault,
Please do not misunderstand. I am grateful for your response even though I was already aware of the option you proposed which really did not provide to me a solution that Martin did. You've been very helpful in the past and I look forward to working with you going forward. I look for a "shooting solution" and Martin provided that for me.
Thank you, once again.
0
Frank FreeseAuthor Commented:
Martin,
Would your solution be in the Activate worksheet section as a sub-procedure?
0
Martin LissOlder than dirtCommented:
It should be in the Worksheet_Change event exactly like I posted. If you don't already have code in that event, just go to Visual Basic, Open the code page for the sheet and copy/paste my complete example.
0
Frank FreeseAuthor Commented:
Did that - does beep but changes are allowed?
0
Frank FreeseAuthor Commented:
Martin,
The reason for being selective is that if I protect the sheet then the user does not have access to Conditional Formatting which is the exercises I am working on now. I'd like to protect most of the worksheet, yet leave access to Conditional Formatting. Thought you might like to know for such a "strange" need.
0
Frank FreeseAuthor Commented:
Whoa! It's working now. I rebooted this workstation, launched Excel and now it is working.
It appears that the best thing ging forward is to reboot this networked workstation first to make sure everything is OK.
Thanks Martin
0
Martin LissOlder than dirtCommented:
If you protect the sheet like this you shouldn't need any code.

Allow formatting
0
Frank FreeseAuthor Commented:
Always looking after me! That's perfect....
Thanks for the follow-up.
0
Martin LissOlder than dirtCommented:
You're welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.