Thread: lock cell
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default lock cell

Don,

I am a novice to visual basic. I used the calculation event originally
because I just wanted to monitor the initial event in Column O but forgot
about the requirement in Column Q. Could were I have it located be the
reason it is not working for me?

Thanks fo the help,
Mike



"Don Guillett" wrote:

I tested OK. Why use a calculation event which will fire with EACH
calculation. Why not a worksheet_change event that fires with col O or col Q

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"MIke" wrote in message
...
Can anyone help me with the following code? I am trying to lock a row
based
on the results of two formulas. If either one of the results are greater
then a certain value then the row will lock. The following code locks the
cell if the first condition is met but not the second. Is there another
way
I could get it to check the second condition. Any help would be greatly
appreciated.

Thanks,
Mike

Private Sub Worksheet_Calculate()
Dim myCell As Range
On Error GoTo ws_exit:
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="justme"
For Each myCell In Range("O7:O37")
If myCell.Value 100 Or myCell.Offset(0, 2).Value 12.5 Then
Range(myCell.Offset(0, -1), myCell.Offset(0, -13)).Locked = True
Else
Range(myCell.Offset(0, -1), myCell.Offset(0, -13)).Locked = False
End If
Next myCell
ActiveSheet.Protect Password:="justme"

ws_exit:
Application.EnableEvents = True
End Sub