View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Colin Hayes Colin Hayes is offline
external usenet poster
 
Posts: 465
Default Protect_Unprotect Macro modification.

In article , Dave Peterson
writes
I'm not sure which ones you want turned back on:

wkSht.Protect Password:=PWORD

Wksht.Protect password:=PWORD DrawingObjects:=False, Contents:=True, _
Scenarios:= True, AllowFormattingColumns:=True, _
AllowInsertingColumns:=True, AllowInsertingRows:=True, _
AllowDeletingRows:=True, AllowFiltering:=True, AllowFormattingRows:=True

I just chose those at random.



Hi Dave

Ok Thanks. I'm not sure where to place this in the macro - I'm getting
red errors when I try to paste it in. If you could advise on that I'd be
grateful.

It's just row formatting i need switched on.

Thanks



Colin Hayes wrote:

Hi Dave

Thanks for getting back to me on this. I'm grateful for your advice ,
and did think that what you suggest was in fact exactly what I'm doing.
I'm posting my existing code , with the additional code I need to
incorporate and asking if anyone with greater expertise can help marry
the two.

My existing code actually undoes the toggled settings. I have the code
to produce the settings I need , I just don't know how to put them into
my macro so that the settings remain in place when I run it.

Sorry if I wasn't clear before.

^_^

In article , Dave Peterson
writes
I think that the safest thing to try is to record a macro when you protect a
worksheet and toggle the settings that you want checked.

You'll see the code you need to add to your code.

If you have trouble incorporating the changes, post the recorded macro code

and
I'm sure you'll get help.

Colin Hayes wrote:

Hi

I use this macro to protect and unprotect all the worksheets in my
workbook :

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

it works very well , but unfortunately resets all the protection
parameters to the minimum. I need to add a line to it so that it will
maintain formatting of rows in the protected sheet.

AllowFormattingRows:=True

but I'm not sure where i can incorporate it into the code. Can someone
help?

Thanks.





Are you aware that we also buy CDs, Vinyl and DVDs? Send your lists of
unwanted items to and well quote you a price€¦


You can browse and buy direct from my full list of items at these addresses :

http://s1.amazon.co.uk/exec/varzea/t.../026-3393902-9
050050

or:

http://www.CDandVinyl.co.uk

or :

http://www.netsoundsmusic.com/chayes

or:

http://chayes.musicstack.com



To DOWNLOAD the full catalogue click here :


http://www.chayes.demon.co.uk/CDandV..._catalogue.exe



Best Wishes ,

Colin Hayes.



TEL / FAX : (UK) (0)208 804 9181