Solved

Lock selected cells without protecting worksheet

Posted on 2013-11-24
18
2,484 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:Frank Freese
  • 9
  • 7
  • 2
18 Comments
 
LVL 1

Expert Comment

by:Dephault
ID: 39673329
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
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39673386
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
 

Author Comment

by:Frank Freese
ID: 39673413
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 39673417
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
 

Author Comment

by:Frank Freese
ID: 39673424
thanks Martin - it looks like I can apply this to my model.
0
 

Author Closing Comment

by:Frank Freese
ID: 39673425
great work - I am grateful, as always
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39673430
And as always you're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0
 
LVL 1

Expert Comment

by:Dephault
ID: 39673432
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39673434
If fh_freese wants to get moderator support to change his points assignment I don't have a problem.
0
 

Author Comment

by:Frank Freese
ID: 39673440
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
 

Author Comment

by:Frank Freese
ID: 39675736
Martin,
Would your solution be in the Activate worksheet section as a sub-procedure?
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39675775
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
 

Author Comment

by:Frank Freese
ID: 39675847
Did that - does beep but changes are allowed?
0
 

Author Comment

by:Frank Freese
ID: 39675893
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
 

Author Comment

by:Frank Freese
ID: 39675919
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39676336
If you protect the sheet like this you shouldn't need any code.

Allow formatting
0
 

Author Comment

by:Frank Freese
ID: 39676400
Always looking after me! That's perfect....
Thanks for the follow-up.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39676411
You're welcome.
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question