ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Locking Cells (https://www.excelbanter.com/excel-programming/411314-locking-cells.html)

Albert Mulder

Locking Cells
 
How can I lock cells so that the info can't be changed. (So that they can't
even try if possible)

Also is there a way that if I have

A1 and E3
and the user needs to input data into A1 before they can input data into E3

I want to be able to lock E3 until A1 has info then Unlock E3

But if the user deletes the data in A1 then the data in E3 is also deleted.

How can this be done?

Herrick Andrews[_2_]

Locking Cells
 
By default, all of the cells are locked; you only need to protect the
worksheet.

For the cells you don't want locked,
Range("<range_address").Locked = False

Then protect the worksheet,
Worksheets("<worksheet_name").Protect

Look in help for "Protect Method" for a list of parameters you can use with
the Protect method.

To Unprotect the worksheet, and make all cells editable again,
Worksheets("<worksheet_name").UnProtect

To set up a dependency between cells E3 and A1, do something like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells(3, 5).Locked = (Trim(Cells(1, 1)) = "")
End Sub

"Albert Mulder" wrote in message
...
How can I lock cells so that the info can't be changed. (So that they
can't
even try if possible)

Also is there a way that if I have

A1 and E3
and the user needs to input data into A1 before they can input data into
E3

I want to be able to lock E3 until A1 has info then Unlock E3

But if the user deletes the data in A1 then the data in E3 is also
deleted.

How can this be done?




Albert Mulder

Locking Cells
 
Could someone explain this more, I don't get it. Sorry!

To set up a dependency between cells E3 and A1, do something like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells(3, 5).Locked = (Trim(Cells(1, 1)) = "")
End Sub






"Herrick Andrews" wrote:

By default, all of the cells are locked; you only need to protect the
worksheet.

For the cells you don't want locked,
Range("<range_address").Locked = False

Then protect the worksheet,
Worksheets("<worksheet_name").Protect

Look in help for "Protect Method" for a list of parameters you can use with
the Protect method.

To Unprotect the worksheet, and make all cells editable again,
Worksheets("<worksheet_name").UnProtect

To set up a dependency between cells E3 and A1, do something like

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells(3, 5).Locked = (Trim(Cells(1, 1)) = "")
End Sub

"Albert Mulder" wrote in message
...
How can I lock cells so that the info can't be changed. (So that they
can't
even try if possible)

Also is there a way that if I have

A1 and E3
and the user needs to input data into A1 before they can input data into
E3

I want to be able to lock E3 until A1 has info then Unlock E3

But if the user deletes the data in A1 then the data in E3 is also
deleted.

How can this be done?






All times are GMT +1. The time now is 02:10 PM.

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