PDA

View Full Version : Protected Cells



ioncila
03-30-2009, 01:16 PM
Hi All

I have this workbook with some sheets. Each sheet has macros to run.

Because there are 5 users (at least) with acess to the workbook, some cells must be locked, for they cannot change the structure of sheets, by erasing formulas or insert/delete rows, etc. What I want is to offer them a restricted acess only to some unprotected cells.

But if I protect other cells by tools menu, macros dont run.

How do I skip that?

Thank you

Bob Phillips
03-30-2009, 02:00 PM
You lock some cells (Format>Cells>Protection), unlock others, and set protection (Tools>Protect).

ioncila
03-30-2009, 02:52 PM
You lock some cells (Format>Cells>Protection), unlock others, and set protection (Tools>Protect).

I did that, but macros contain code lines to "clear.contents" and when I execute with protection activated, they return error to those lines

lenze
03-30-2009, 03:10 PM
In the This WorkBook Module

Private Sub WorkBook_Open()
For Each ws in WorkSheets
ws.protect "password" UserInterFaceOnly:=True
Next ws
End Sub
This will protect the sheets, but allow changes via VBA

lenze

ioncila
03-30-2009, 03:59 PM
In the This WorkBook Module

Private Sub WorkBook_Open()
For Each ws in WorkSheets
ws.protect "password" UserInterFaceOnly:=True
Next ws
End Sub This will protect the sheets, but allow changes via VBA

lenze

Still not working

Private Sub WorkBook_Open()
For Each ws In Worksheets
ws.Protect "password", UserInterFaceOnly:=True
Next ws
End Sub

What is missing?

lenze
03-30-2009, 05:09 PM
What exactly is happening? Where did you place the code? Did you save and reopen the WorkBook?

lenze

ioncila
03-31-2009, 03:07 AM
What exactly is happening? Where did you place the code? Did you save and reopen the WorkBook?

lenze

Sorry for last reply. I did exactly what you told me to do, except save and reopen.

It works just fine, as I expected so.

Thank you very much for your help and time.

You all do a great job

ioncila