Cell lock

G

Guest

Is it possible to change the characteristics of a cell based on content of
another cell.
My problem is:
If c2=0 then e10 should be locked
if c2=1 then e10 should be unlocked.

I have conditional formatting on this cell e10 which is depending on the
content of c2, ie.
e10 = no fill = locked
e10 = yellow fill = unlocked.

If possible I would like to use the latter as condition.
Thanks
 
F

Fadi Chalouhi

Hi Adam,

here's the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("C2").Value = 0 Then
ActiveSheet.Unprotect
Range("E10").Locked = True
Range("E10").Interior.ColorIndex = xlNone
ActiveSheet.Protect
End If
If Range("C2").Value = 1 Then
ActiveSheet.Unprotect
Range("E10").Locked = False
Range("E10").Interior.ColorIndex = 6

ActiveSheet.Protect
End If
End Sub

Obviously, cell C2 is unprotected.
you might also want to add some passwords to the Protect/Unprotect
code.

HTH

Fadi
www.chalouhis.com/XLBLOG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top