locked cell not locked

W

Wanna Learn

Hello
Below is my code
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$N$11" Then
ActiveSheet.Protect "pass"

Else
If Target.Address = "$H$41" Then
ActiveSheet.Unprotect "pass"

This is what I want to do- when person completes cell N11 active sheet is
protected - until all cells are completed to H 41. when person completes H
41 active sheet is unprotected.
the above code works, BUT it does not recognized AB 11 as a locked cell
eventhough the cell is formatted as locked. thanks
 
G

Gary''s Student

To Protect a cell, try something like this first:

Sub lock_um()
ActiveSheet.Unprotect
Range("A1").Locked = True
ActiveSheet.Protect
End Sub
 

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