Solved

Excel Conditional Cell Protection

Posted on 2010-08-23
7
643 Views
Last Modified: 2012-06-27
I have a spreadsheet with rows which users need to edit before final approval but not afterward.  I need some help with conditional protection.  Basically, in the attached spreadsheet, if L5 is <> null, I need entire row 5 protected.  If L5 = null, then the row should be open for editing.  And then this same criteria applied to the remainder of the spreadsheet, with the L column from cell 5 onward as the key.  Can anyone help?
PropertyPass.xls
0
Comment
Question by:mrherndon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 24

Expert Comment

by:broomee9
ID: 33505209
Your sheet is password protected.  Unprotect and re-post.
0
 

Author Comment

by:mrherndon
ID: 33505277
Apologies.  Unprotected.
PropertyPass.xls
0
 
LVL 24

Accepted Solution

by:
broomee9 earned 500 total points
ID: 33505360
OK, try this:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo errHandler

    Application.EnableEvents = False

    If Target.Column = 12 And Target.Count = 1 Then
        Call UnProtect
        If Target.Value <> "" Then Rows(Target.Row).Locked = True
        Call Protect
    Else
    End If

finished:
    Application.EnableEvents = True
    Exit Sub

errHandler:
    MsgBox Err.Number & " - " & Err.Description
    Resume finished

End Sub

Open in new window

PropertyPass-2-.xls
0
Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

 

Author Comment

by:mrherndon
ID: 33505583
Thanks.  It works great on the "test" line.  But the rest of the sheet is unaffected.  What am I missing?
0
 
LVL 24

Expert Comment

by:broomee9
ID: 33506400
The values are already filled in.  This code is triggered when you enter a new value in column L.  So either protect the cells now for each line that already has a value, or remove the initials and then re-add them back in and the code will execute for each one.
0
 

Author Comment

by:mrherndon
ID: 33506605
I see.  So, going forward it will lock new data.  Existing data I can manually lock.  Do I understand you correctly?
0
 
LVL 24

Expert Comment

by:broomee9
ID: 33521099
Yes, that's correct.
0

Featured Post

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

751 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