ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Disable a range of Cells (https://www.excelbanter.com/excel-worksheet-functions/90987-disable-range-cells.html)

SU

Disable a range of Cells
 
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.

Ron de Bruin

Disable a range of Cells
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"SU" wrote in message ...
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.





All times are GMT +1. The time now is 08:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com