Col Delane
Active Member
- Joined
- Jan 14, 2014
- Messages
- 304
NOTE:This post is NOT about allowing a user to Expand (+)/Collapse (-) grouped rows/columns on a worksheet, but is about increasing/decreasing the number of rows/columns that are included in the existing Row/Column Outlines.
I have the following code in a macro that toggles sheet protection on or off.
This works mostly fine, including allowing users to Expand/Collapse any EXISTING grouping of rows/columns. However, it disables the Group / Ungroup commands on the Outline tab of the Ribbon (XL 2016), thus preventing the user from changing which rows/columns are Grouped. This is the problem I wish to resolve.
As Grouping & Outlining seem to be treated by Excel as a type of formatting, I have tried adding the following elements to the .Protect line in the code above, but to no avail!
Are there any changes I can make to the above code that will allow a user to Group more rows/columns than already Grouped, or to Ungroup any rows/columns that are already Grouped (but without having to Unprotect the sheet to allow a user to change the extent of the Outline, and then Protect the sheet when they're finished)?
I have the following code in a macro that toggles sheet protection on or off.
Code:
With aSheet
.Protect Password:=pw, AllowFiltering:=aProtectStatus, DrawingObjects:=aProtectStatus, contents:=aProtectStatus, [COLOR=#0000ff][B]UserInterfaceOnly:=True[/B][/COLOR]
.[COLOR=#0000ff][B]EnableOutlining = True[/B][/COLOR]
End With
This works mostly fine, including allowing users to Expand/Collapse any EXISTING grouping of rows/columns. However, it disables the Group / Ungroup commands on the Outline tab of the Ribbon (XL 2016), thus preventing the user from changing which rows/columns are Grouped. This is the problem I wish to resolve.
As Grouping & Outlining seem to be treated by Excel as a type of formatting, I have tried adding the following elements to the .Protect line in the code above, but to no avail!
Code:
AllowFormattingRows:=True, AllowFormattingColumns:=True
Are there any changes I can make to the above code that will allow a user to Group more rows/columns than already Grouped, or to Ungroup any rows/columns that are already Grouped (but without having to Unprotect the sheet to allow a user to change the extent of the Outline, and then Protect the sheet when they're finished)?