My VB Code doesn't work when workbook is protected/shared
Posted by Anita on February 08, 2002 6:09 AM
Can anyone help with this? I have the following code where I am unlocking and locking cells based on the value of another cell but I have to "protect & share" the workbook and I get an error message that says "Unprotect method of worksheet class failed" when I go to click in the cell. Any help would be appreciated!
Private Sub WORKSHEET_CHANGE(ByVal Target As Range)
If Target.Column = 15 Or Target.Column = 17 Then
If Cells(Target.Row, 15) = "Promotion" Or _
Cells(Target.Row, 17) = "1" Then
ActiveSheet.Unprotect ("password")
Cells(Target.Row, 19).Locked = True
Cells(Target.Row, 19).Interior.ColorIndex = 34
Cells(Target.Row, 19).ClearContents
ActiveSheet.Protect ("password")
Else
ActiveSheet.Unprotect ("password")
Cells(Target.Row, 19).Locked = False
Cells(Target.Row, 19).Interior.ColorIndex = 0
ActiveSheet.Protect ("password")
End If
End If
End Sub