Thanks for the private message, I'm just terrible at getting back to things.
I wasn't able to find the exact source I pulled this code from, but here's a simple solution:
Click the Record Macro button in the bottom left corner of your workbook, then protect your sheet, and turn on all options! Stop recording, then hit Alt+F11 and go check out the newest module of your workbook and view the code.
Here's what I got:
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True, AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End Sub
Each of the properties set after the protect are things you can dictate in your own macro.
Taking that information, we can inject it into what you already have.
Note how some lines end in " _"? This is a way to jump to the next line down so that the code doesn't continue off the screen.
In other words:
As long as _
I end each _
line with a " _" _
Visual Basic code will _
recognize it as _
a single continuous code.
If it helps you understand or organize better, you can do it after each property.
You can also begin a line with an apostrophe to create a comment, which tells VB to ignore the whole line. (It's a good way to leave yourself notes but don't try to do it in the middle of a line of code, even after a _.)
Private Sub Workbook_Open()
'This VB Code goes off after opening and unprotects the workbook to enables outlining
'It then reprotects the book but with enabled insertion/deleting of rows, and formatting of cell
'daffodil is somewhat nifty
With Worksheets("yoursheetname")
.Unprotect "password"
.EnableOutlining = True
.Protect "password", _
contents:=False, _
userInterfaceOnly:=False, _
DrawingObjects:=False, _
contents:=False, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=True, _
AllowSorting:=False, _
AllowFiltering:=False, _
AllowUsingPivotTables:=False
End With
End Sub
And there's your code with every possible option as far as protection options, with Formatting, Delete Rows, & Insert Rows enabled.
Bookmarks