View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Protect/unprotect sheet with password with VBA?

Try:

Const PWORD As String = "1234567"
With ActiveSheet
.Unprotect Password:=PWORD
With .Range("I4:N6")
.Locked = False
.FormulaHidden = False
End With
.Protect Password:=PWORD
End With




In article ,
dragontale wrote:

All,

I have the following code to protect sheet, then unlock cetain cells
based on the login. So people can onlu modify certain cells. And then
protect the sheet with password, so no one can unprotect the sheet
without the password:

ActiveSheet.Unprotect

Range("I4:N6").Select
Selection.Locked = False
Selection.FormulaHidden = False

ActiveSheet.Protect
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveSheet.Protect Password:="1234567"

But it doesn't work. It ask me for password.

Any suggestion will be appreciated.


---
Message posted from http://www.ExcelForum.com/