Lock and protect cells without protect the sheet

  • Thread starter Thread starter Christian
  • Start date Start date
C

Christian

Dear experts,

I would like lock and protect cells without protect the sheet.

Thank You

Christian
 
Hi Christian,

Whilst the locked property of the cells can be set, the locking (and
protection) is only activated when the sheet is protected.

What are you trying to do exactly?
 
Not possible as such.
If you want to protect the cells from users i.e. ser manually should not
be able to change the cell values or any other properties then you can
add a code in that sheet's Selection Change.

By default all the cells in the worksheet are locked, but not formuala
hidden.
For the cells which you want to protect (from the users), go to Format
Cells and on Protection Tab check the box 'Hidden'. Below code will not
allow the user to selct cell (or a range including the cell) for which
the Hidden box is checked.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c
Application.EnableCancelKey = xlDisabled
For Each c In Target.Cells
If c.FormulaHidden Then
c.Offset(0, 1).Select
MsgBox "The cell left to the now selected cell" _
& "is protected and you can't select it."
Exit For
End If
Next c
Application.EnableCancelKey = xlInterrupt
End Sub

If you yourself want to change back the hidden box to unchcecked enter
in design mode first then you can change
(and mind you, so can a user if he knows enough!)
Sharad
 
actually, it IS possible.

Go to the IDE, and in the Project Viewer, select the sheet that you want to
portect. Select the Properties Window and you'll see a proprty called
"ScrollArea"
This is the range that the cursor can move in. Usually left blank, but you
could setthis to a cell, like A1
or A1:G5
the effect limits where the user can select....so your data can only be seen
and th eformula remains hidden... and obviously a cell cannot be changed if
it cannot be selected !

Not widely used, but its a good way to "protect" data.
 
Wow! That's so simple!
Though this can not be assigned to non continuous range,
I don't know if the OP can use this but
I found it very useful, in many of my templates, I need to give
the user access only to a certain (continuous) range.
And with what you told, even if the user goes to design mode, it
still work!

Thanks
Sharad
 
Sharad Naik said:
Wow! That's so simple!
Though this can not be assigned to non continuous range,
I don't know if the OP can use this but
I found it very useful, in many of my templates, I need to give
the user access only to a certain (continuous) range.
And with what you told, even if the user goes to design mode, it
still work!

Thanks
Sharad

Thank You,

Christian
 

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