Hello,
When I manually copy a sheet using VBA the protection on it stays, which is exactly what I want.
However, when I do this using VBA, the protection disappears.
I need to have the protection remain, it's initially applied in the ThisWorkbook module as it is special in order to allow a user to expand/collapse groups.
I'd like to have this protection copied to all of my sheets.
The sheets are created based off of a template, this template is the one with the protection and because they don't exist before, I can't just add them into the code for when the workbook opens.
Any ideas?
Here are the code snippets:
Private Sub Workbook_Open()
With Worksheets("Template S")
.Protect Userinterfaceonly:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True
.EnableOutlining = True
End With
End Sub
and
Dim I As Integer
For I = 1 To Range("CountCC").Value
Dim MySheetNameS As String
MySheetNameS = Range("CC_" & I).Value & " S"
Sheets("Template S").Copy After:=Sheets(Worksheets.Count)
ActiveSheet.Name = MySheetNameS
Next I
Any help would be appreciated.
Thanks
Bookmarks