This assumes that we start with the worksheet unprotected and all cells un-locked. Place the following event macro in the worksheet code area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim B1 As Range, OtherBees As Range
Set B1 = Range("B1")
Set OtherBees = Range("B6,B9,B22,B50")
If Intersect(Target, B1) Is Nothing Then Exit Sub
ActiveSheet.Unprotect
Cells.Locked = False
Application.EnableEvents = False
If UCase(B1.Value) = "YES" Then
OtherBees.Value = "NO"
OtherBees.Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
OtherBees.Locked = False
OtherBees.ClearContents
End If
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use:
- right-click the tab name near the bottom of the Excel window
- select View Code - this brings up a VBE window
- paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
- bring up the VBE windows as above
- clear the code out
- close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!