M
MIke
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
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