Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default VBA code - protect and unprotect a sheet

Can someone please provide code to protect and unprotect a
sheet. Assume sheet name is "Sam" and password
is "Malone". Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA code - protect and unprotect a sheet


"Jeff" schreef in bericht
...
Can someone please provide code to protect and unprotect a
sheet. Assume sheet name is "Sam" and password
is "Malone". Thanks.


Sheets("Sam").Unprotect password:="Malone"
Sheets("Sam").protect password:="Malone"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default VBA code - protect and unprotect a sheet

Sub Protect()

Sheets("Sam").Protect Password:="Malone"
End Sub

---------------------------------------------

Sub UnProtect()

Sheets("Sam").UnProtect Password:="Malone"
End Sub

---------------------------------------------

If you just want a routine to toggle it, then the following from JE McGimpsey
will do that:-

Sub ToggleProtect()

Const PW As String = "Malone"

With Sheets("Sam")
If .ProtectContents = False Then
.Protect PW
Else
.UnProtect PW
End If
End With

End Sub

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
Newsgroups - Where you really can get a free lunch!!
----------------------------------------------------------------------------



"Jeff" wrote in message
...
Can someone please provide code to protect and unprotect a
sheet. Assume sheet name is "Sam" and password
is "Malone". Thanks.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003


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
Protect, unprotect Pyrite Excel Discussion (Misc queries) 0 August 15th 08 03:18 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Protect - Unprotect Sheet - Visual Source Safe [email protected] Excel Discussion (Misc queries) 0 June 6th 06 09:13 PM
Code to protect sheet Conditional Formatting Excel Worksheet Functions 1 December 21st 05 11:04 PM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM


All times are GMT +1. The time now is 02:08 AM.

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

About Us

"It's about Microsoft Excel"