Locking Cells

  • Thread starter Thread starter Albert Mulder
  • Start date Start date
A

Albert Mulder

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?
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top