View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Minitman Minitman is offline
external usenet poster
 
Posts: 293
Default Sheet Protection Question

Hey Tim,

Thanks for the reply.

Do you mean something like this:

Worksheets("Sheet1").Activate
ActiveSheet.Unprotect
For i = 1 To 100
Worksheets("Sheet1").Range("pfCell_" & i).Locked = False '<<<<
Next i

With ActiveSheet
.Protect _
.EnableSelection = xlNoSelection
End With

It still gives this same error message.

Run-time error '1004':
Unable to set the locked property of the range class

Debug highlighted the line in front of the '<<<<, the same as last
time.

That seemed like a possibility, but when I plugged in the unprotect in
front of the locking code, it made no difference.

Any other ideas as to why this is erroring out

-Minitman



On Thu, 8 May 2008 22:01:17 -0700, "Tim Williams" <timjwilliams at
gmail dot com wrote:

I think you can't change the locked properrty while the sheet is protected.

Tim


"Minitman" wrote in message
.. .
Hey IT Dev Guy,

Thanks for the reply.

I didn't make myself clear. I am looking for a vba solution.

To simplify, The sheet has two states - Locked for viewing and
unlocked for editing. A CommandButton is used to toggle between the
states.

Here is the code I am trying to use to unlock named ranges pfCell_1 to
pfCell_100:

For i = 1 To 100
Worksheets("Sheet1").Range("pfCell_" & i).Locked = False '<<<<
Next i

So far all I get is this error message:

Run-time error '1004':
Unable to set the locked property of the range class

Debug highlighted the line in front of the '<<<<

Any ideas as to what is wrong or missing in this code?

Any help will be greatly appreciated.

-Minitman


On Thu, 8 May 2008 11:10:00 -0700, IT Dev Guy
wrote:

If you go to the Properties for the button (or combobox or individual
cells
or whatever else doesn't need to be locked), you'll probably see that the
'Locked' field is checked -- that's the default. Simply uncheck it and
relock your sheet and you should be fine.

"Minitman" wrote:

Greetings,

I have a worksheet with linking formulas in 79 cells (named ranges),
ToolbarsControl ToolboxCommandButtons and a ToolbarsFormsComboBox.

This worksheet is set up as a form to view individual records chosen
from the ComboBox. This form is setup to do one of two tasks. First
view the record. And second, edit the record.

To view: I need to only see the information in the record and not be
able to change anything - until I click the "Start Edit" button.

To edit: All of the formulas are changed into values. Then I can edit
any or all of the cells.When finished, I click the "End Edit" button,
which saves the edited version of the record into the "Customer List"
sheet and then puts the formulas back into the cells.

The only thing I am missing is how to keep from overwriting the
formulas (in the view mode) with vba. The problem I ran into with
Protect was that the CommandButtons were also protected and I need
them to always be unprotected. Is there a way to lock everything but
the CommandButtons and the ComboBox?

I'm not even sure if protection is what I need. Security is not an
issue here. Overwriting the formulas is.

Another possibility would be if when the user entered any of the cells
on that page, to automatically trigger the edit mode. The cells all
have names (pfCell_4 thru 79 - eg. pfCell_4, pfCell_5, ... pfCell_79).

Any help will be greatly appreciated.

-Minitman