Unlock Locked Cell based on another Cell Value

kiwikiki718

Board Regular
Joined
Apr 7, 2017
Messages
80
Office Version
  1. 365
Platform
  1. Windows
I have a spread sheet that is Locked/Protected. I want to be able to unlock cell D10 based on the Value of cell C10. so if cell C10 ="Other" I want cell D10 to unlock. else then Cell D10 to remain Lock.

thank You in advance
 
Thank you @Joe4 I forgot about that...

This will clear D10 :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Or Target.Address <> Range("C10").Address Then Exit Sub
    
    ActiveSheet.Unprotect "YourPassWord"
    
    If Range("C10").Value = "Other" Then
        Range("D10").Locked = False
    Else
        Range("D10").ClearContents
        Range("D10").Locked = True
    End If
    
    ActiveSheet.Protect Password:="YourPassWord"
End Sub

One more thing Louis,

If I had multiple cells in column C that I wanted to apply this code to how would I be able to do so?

example I want to apply this to cells C10:C14 that equals other.

thanks in advance.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Then you might change it so Something like this :

Assuming you always want to work with "C" that locks/unlocks "D".
Just change the range in the first line of code to your needs :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Or Intersect(Target, Range("C10:C14")) Is Nothing Then Exit Sub
    
    ActiveSheet.Unprotect "YourPassWord"
    
    If Target.Value = "Other" Then
        Target.Offset(0, 1).Locked = False
    Else
        Target.Offset(0, 1).ClearContents
        Target.Offset(0, 1).Locked = True
    End If
    
    ActiveSheet.Protect Password:="YourPassWord"
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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