Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 465
Default Preserving cell formatting when protecting or unrprotecting



HI

I use this code to protect / unprotect my worksheets.


Sub Protect_Unprotect()
'
' Protect_Unprotect Macro

' Shortcut Ctrl + z
' Protects / Unprotects by turn all sheets in a workbook

'
Const PWORD As String = "12071956"
Dim wkSht As Worksheet
Dim statStr As String

For Each wkSht In ActiveWorkbook.Worksheets
With wkSht
statStr = statStr & vbNewLine & "Sheet " & .Name
If .ProtectContents Then
wkSht.Unprotect Password:=PWORD
statStr = statStr & ": Unprotected"
Else
wkSht.Protect Password:=PWORD
statStr = statStr & ": Protected"
End If
End With
Next wkSht
MsgBox Mid(statStr, 2)


End Sub


What I'd like to do is to add a line or two which qualifies the protect
element so that it will allow for cell formatting once the sheet is
protected.

Can someone suggest a modification of the above ot allow for this?


Thanks.
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
Preserving formatting in a formula. NLiles Excel Discussion (Misc queries) 3 May 18th 07 07:10 PM
MS Query from Excel - Preserving formatting, validation and Commen scott Excel Discussion (Misc queries) 2 November 27th 06 07:30 PM
Preserving Cell References Daiv Excel Discussion (Misc queries) 3 August 3rd 06 07:27 PM
preserving cell format bob777 Excel Discussion (Misc queries) 2 November 4th 05 12:53 PM
Preserving cell reference after a sort Scott Emery New Users to Excel 1 March 20th 05 02:41 PM


All times are GMT +1. The time now is 04:58 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"