View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Russell Plummer Russell Plummer is offline
external usenet poster
 
Posts: 4
Default Excel97 - Worksheet Protection Question

Trying to create a form for users which is locked until they press a button
to enter values. I'm having a problem getting the worksheet to unlock so I
can set a range for data entry then lock again. Code fragment is:

Worksheets(WkShtName).Unprotect
Worksheets(WkShtName).Range("B3").Locked = False
Worksheets(WkShtName).Protect

When I try to test this I get an "Error 1004 Unprotect Method of Worksheet
Class failed" on the first line if the Worksheet is locked, and "unable to
set the Locked property of the Range class" if the sheet is unlocked when I
invoke the code.

Stranger still, the code is invoked from a button handler - if I use the
button I get error above, but if I run the code under the VBA Editor, then
it runs OK IF the worksheet is unprotected..hmmm

Can anyone point me in the right direction to make this work please

Thanks

Russell