View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Dale...[_2_] Dale...[_2_] is offline
external usenet poster
 
Posts: 2
Default spread sheet protection over several tabs

thanks much Dave, this worked great...
where are you located?

"Dave Peterson" wrote:

I didn't have any trouble with the unprotection (did you when you tested?). But
protecting did cause a problem.

I changed both subs -- just so the code looked consistent:

Option Explicit
Sub UnprotectAll()
Dim wks As Object
Dim SelSheets As Object

Set SelSheets = ActiveWindow.SelectedSheets
ActiveWindow.SelectedSheets(1).Select

For Each wks In SelSheets
With wks
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
On Error Resume Next
.Unprotect
If Err.Number < 0 Then
MsgBox "Something went wrong with: " & wks.Name
Err.Clear
'exit for 'stop trying???
End If
On Error GoTo 0
End If
End With
Next wks

End Sub
Sub ProtectAll()
Dim wks As Object
Dim SelSheets As Object

Set SelSheets = ActiveWindow.SelectedSheets
ActiveWindow.SelectedSheets(1).Select

For Each wks In SelSheets
With wks
If .ProtectContents = True _
Or .ProtectDrawingObjects = True _
Or .ProtectScenarios = True Then
'do nothing, it's already protected
Else
On Error Resume Next
.Protect
If Err.Number < 0 Then
MsgBox "Something went wrong with: " & wks.Name
Err.Clear
'exit for 'stop trying???
End If
On Error GoTo 0
End If
End With
Next wks
End Sub




Dale... wrote:

Dave,
Once you select more than one tab the "Unprotect Sheet" option is not
available. How whould that work in a Macro? and i not using passwords.
Dale...

"Dale..." wrote:

i would like to be able to turn worksheet protection on and off over several
tabs at one time in a workbook. i have the same range of protected cells on
each tab and in order to edit or change the ranges accross several tabs i
have to turn the protection off by tab. is there a way to select several
tabs at one time and turn protection off for the selected tabs?

Dale...


--

Dave Peterson