Grouping and Protecting worksheet

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

Hi,

I have a spreadsheet in which I have grouped rows. This
gives the tree like structure. I have unlocked cells and
locked certain cells and protected the sheet so people
can only access the unlocked cells. In doing this the
group, expanding and contracting, stops working because
the sheet is protected. I can't find a way to protect
the sheet and still have the expanding and contracting
work.

Please help.

Brad
 
If you already have the outline applied, you can protect the worksheet in code
(auto_open/workbook_open??).

Option Explicit
Sub auto_open()
With Worksheets("sheet1")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub

It needs to be reset each time you open the workbook. (excel doesn't remember
it after closing the workbook.)

(you could use the workbook_open even under ThisWorkbook, too.)

Don't forget to lock the VBA Project, too. Else you'll have inquisitive types
looking at your code and seeing the password.

Inside the VBE, you can lock the project.
Tools|VBAProject Properties|Protection tab.
Give it a memorable password and lock the project for viewing.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top