View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
john tempest[_2_] john tempest[_2_] is offline
external usenet poster
 
Posts: 27
Default lock/unlock cells

thank you ian but i am still having problems. i get the error ambiguous which
i can understand as i have the following code already in the sheet. how do i
get both sets of code to work on the same sheet
thans again john
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WatchRange As Range

Set WatchRange = Range("B4:B7,B25,B16:H16")

If Application.CountA(WatchRange) = WatchRange.Count Then

Sheet111.Visible = xlSheetVisible
Else
Sheet111.Visible = xlSheetVeryHidden
End If
End Sub

"Ian" wrote:

Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect
If Range("B20").Value < "" Then
Range("B21").Locked = True
Else
Range("B21").Locked = False
End If
If Range("B21").Value < "" Then
Range("B20").Locked = True
Else
Range("B20").Locked = False
End If
ActiveSheet.Protect
End Sub

--
Ian
--
"john tempest" wrote in message
...
say i have 2 cells B20 and B21. when i enter a number in B20 i want B21 to
lock, i also want this to work via versa so if i enter a number in B21 i
want
B20 to lock. this is so a number cannot be put in both cells
is this possible
thankyou john tempest