Lock and unlock with VBA
<p>I have a part lookup file that returns the location from the part number. I also have this file create an upload file based off of the location as certain locations point to a computerized storage system and I am able to upload.</p>

<p>My issue is column A is the part number, B is a control that provides a "1" when the part is in the computerized location and is hidden. column C is open for the count of the part coming in. Since Column C is not necessary for parts outside of the computerized system I am trying to create a VBA code that will lock when Column B is blank and unlock when the value is "1" </p>

<p>The code i have been trying is :</p>

<p>Private Sub Worksheet_Change(ByVal Target As Range)</p>

<pre><code>Dim aCell As Range

Application.EnableEvents = False

If Not Intersect(Range("B:B"), Target) Is Nothing Then
    ActiveSheet.Unprotect "MYPASSWORD" 
    For Each aCell In Range("B:B")
        If Len(Trim(aCell.Value)) = "" Then _
        aCell.Offset(, 1).Locked = True Else _
        aCell.Offset(, 1).Locked = False
    Next
    ActiveSheet.Protect "MYPASSWORD"
End If
</code></pre>

<p>End Sub</p>

<p>I would like to get it where when i hit enter the cursor goes to the count column C if the part is in the computerized system and just go to the next line if it is not.</p>