title: how to use the vb code for the entire column based on the condition
body: <p>I want to disable one cell in excel based on the condition of the previous cell, for example, if A3="xyz" then B3= disable, and I have achieved this by the following code:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
      If Target &lt;&gt; Range("A3") Then Exit Sub
  
      ActiveSheet.Unprotect
  
      If Range("A3").Value = "CNS" Then
          Range("B3").Locked = True
      End If
  
      If Range("A3").Value = "APL" Then
          Range("B3").Locked = False
      End If
  
      ActiveSheet.Protect
  
  End Sub
  </code></pre>
  
  <p>Now I want to use this code for the entire A column. If I enter <code>A4</code> or <code>A5</code>, then the corresponding <code>B4</code> or <code>B5</code> should become disabled.</p>