title: Worksheet keeps Protecting on all cells
body: <p>I have the following code setup but I need it to stop protecting the other cells that does not need to be protected. I cannot unlock the cels via Format cells - Protection because I need certains cells lock when <code>B7:B1000</code> contains text "PA" "PU". If it is blank or has any other text it should not protect those cells.    </p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
  On Error GoTo ErrorHandler
  Application.EnableEvents = False 'prevent infinite event loops
  
  Me.Unprotect ' else won't be able to modify locked cells
  
  If Not Intersect(Target, Range("B7:B1000")) Is Nothing Then
      'User edited a cell in this range.
      With Range("F1:M1").Offset(Target.Row - 1, 0)
          If (Target.Value = "PA" Or Target.Value = "PU") Then
              .Interior.Color = RGB(77, 77, 77) 'gray
              .Locked = True
          Else
              .Interior.Color = RGB(255, 255, 255) 'white
              .Locked = False
          End If
  
      End With
  End If
  
  ExitProcedure:
      Me.Protect
      Application.EnableEvents = True
      Exit Sub
  ErrorHandler:
      MsgBox Err.Description
      Resume ExitProcedure
  
  Set wkB = Nothing
  
  End Sub
  </code></pre>