Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to lock a range of cells based on two conditions. The first
condition is if the value in range (o7:037) 8. The second condition is if the value in range Q7:Q37 12. If either of these condition are met I need the corresponding range B:N to lock. I have the following code supplied to me by Gord Dibben and it works great when evaluating one condition. He has suggested using IF OR statements to evaluate the two conditions. I am not that familiar with VBA code and I can not get the code to work. Can anyone point me in the right direction? 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 8 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lock a formula to a column of cells | Excel Worksheet Functions | |||
lock cells based on interior color | Excel Discussion (Misc queries) | |||
lock cells based on formula result | Excel Discussion (Misc queries) | |||
Lock formula cells? | Excel Discussion (Misc queries) | |||
lock only formula cells without protecting sheet - leave open | Excel Programming |