Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect/unprotect sheet with password with VBA?

All,

I have the following code to protect sheet, then unlock cetain cell
based on the login. So people can onlu modify certain cells. And the
protect the sheet with password, so no one can unprotect the shee
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Forgot the password (to unprotect a sheet) Venkatesh V Excel Discussion (Misc queries) 1 March 29th 06 08:32 AM
Password - Protect, UnProtect MrAlMackay Excel Programming 5 January 19th 05 07:23 PM
VBA code - protect and unprotect a sheet Jeff Excel Programming 2 December 2nd 03 11:44 PM


All times are GMT +1. The time now is 07:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"