Expand/Collapse in a Protected Workbook

drangel

New Member
Joined
Aug 29, 2014
Messages
18
Hi all,

I am attempting to allow users to expand/collapse (+/-) groupings I already created under a protected worksheet (workbook as well). I would like VBA to (auto) run when worksheet is open. Below is the code I have:

Private Sub Workbook_Open()
With Worksheets("TRUCK Utilization")
.Unprotect Password:="password"
.EnableOutlining = True
.Protect Password:="password", contents:=True, UserInterfaceOnly:=True
End With
End Sub


When I test- open up workbook- and attempt to collapse grouping, a message box pops up saying, "You cannot use this command on a protected sheet. To use this command, you must first unprotect the sheet..."

Problem is that the expand/collapse feature only works after I open VB and run code (after I run it and toggle back to worksheet, it works). Is there a way to have it run without the end user having to go into VBA to have it work in Excel 2010? Possibly have it run when workbook is open on a different computer?
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,215,377
Messages
6,124,598
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top