Disable a range of Cells

S

SU

How can I disable a range of cells only for them to become active depending
on the value of another specific cell? I don't want the cells to accept any
input data unless it meets the criteria specified on another cell. For
instance, on the 29th day of February.

Many thanks.
 
R

Ron de Bruin

Hi SU

This example unlock the cells A5:C10 if cell A1 = "ron"
(Unlock cell A1 also before you try it)

It unprotect/protect the sheet without a password this example but you can add a password if you want


'Place the code in the Sheet module
'
'Right click on a sheet tab and choose view code
'Paste the code there
'Alt-Q to go back to Excel


Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
If Target.Value = "ron" Then
Me.Unprotect
Range("A5:C10").Locked = False
Me.Protect
Else
Me.Unprotect
Range("A5:C10").Locked = True
Me.Protect
End If
End If
End Sub
 
Top