Hello.

I am new to excel macro programming and could be mucking this up. The problem I am trying to solve is I have 2 columns E and F. If the user enters data in F2 then I want to automatically lock col E2. And if the user enters data in Col E2 I want to lock Col F2. This excel file is something that has a set columns which the user can use to insert rows which will be uploaded into our website. Therefore this has to work for all rows.

From research on the web I found I can do something like this. What works here is setting range on Col E, and marking 'No Insert' if E has some data inserted. For some reason the Locked is not working. Any help on why would be really helpful.

The 2nd Q is when I make the range fro E:F, I am not sure how to code the toggle logic in.
Thank you for your help.

Private Sub Worksheet_Change(ByVal Target As Range)
' Code goes in the Worksheet specific module
Dim rng As Range

Set rng = Target.Parent.Range("E:E")

If Target.Count > 1 Then Exit Sub

If Intersect(Target, rng) Is Nothing Then Exit Sub
'
If Not IsEmpty(Target.Value) Then
' FOR SOME REASON LOCKED IS NOT WORKING BUT SETTING VALUE IS. THEREFORE .VALUE IS WHAT I AM TESTING WITH
'Range(Cells(Target.Row, "F"), Cells(Target.Row, "F")).Locked = True

Range(Cells(Target.Row, "F"), Cells(Target.Row, "F")).Value = "No Insert"
End If


Ambika