View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B Paul B is offline
external usenet poster
 
Posts: 709
Default Protect sheets w/o user password prompt

Try this,

Dim Sht As Worksheet
Const Pass As String = "hello"

On Error Resume Next
For Each Sht In ThisWorkbook.Worksheets
With Sht
..Cells.Locked = False
..Cells.SpecialCells(xlCellTypeFormulas).Locked = True
..Protect UserInterfaceOnly:=True, Password:=Pass

End With
Next Sht


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"hotherps" wrote in message
...

When I run this code in the open workbook event. It locks all of the
formulas but still allows the use of command buttons.

But if I uncomment the line below it promps the user for a password
once for each sheet in the workbook(9 shts)

If I comment it out it protects everything I want but protection can be
turned off without a password

Dim Sht As Worksheet
Const Pass As String = "hello"

On Error Resume Next
For Each Sht In ThisWorkbook.Worksheets
With Sht
Protect UserInterFaceOnly:=True
'.Unprotect Password:=Pass
cells.Locked = False
cells.SpecialCells(xlCellTypeFormulas).Locked = True
Protect Password:=Pass
End With
Next Sht


--
hotherps
------------------------------------------------------------------------
hotherps's Profile:

http://www.excelforum.com/member.php...fo&userid=5055
View this thread: http://www.excelforum.com/showthread...hreadid=320053