lock a range question
this appears to work, can anyone verify?
Private Sub Worksheet_Change(ByVal Target As Range)
For z = 4 To 56
For y = 11 To 16
If Target.Row = z And Target.Column = 27 _
And Target.Value = "x" Then
Range(Cells(Target.Row, z), Cells(Target.Row, y)).Locked =
True
End If
Next
Next
End Sub
--
Gary
"Rowan Drummond" wrote in message
...
If you were to start out with all cells on the sheet unlocked then you
could use a worksheet change event similar to this. This checks entry in
columm A and then locks columns C,D and E on that row:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 And Target.Column = 1 _
And Target.Value = "x" Then
Me.Unprotect Password:="mypassword"
Range(Cells(Target.Row, 3), Cells(Target.Row, 5)).Locked = True
Me.Protect Password:="mypassword"
End If
End Sub
Hope this helps
Rowan
Gary Keramidas wrote:
what would be the best way to do this:
if an x is entered in a cell, lock a range of cells in that same row so
nothing in that range could be entered?
|