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. |
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" |
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 |
All times are GMT +1. The time now is 12:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com