Grouping and Protecting Cells

G

Guest

Hi
I have grouped cells in my worksheet. When I protect the worksheet I can no longer expand and collapse the groupings. I searched the forums and someone suggested putting in this code (which would have to be run each time the spreadsheet is opened)

Option Explici
Sub auto_open(
With Worksheets("sheet1"
.Protect Password:="hi", userinterfaceonly:=Tru
.EnableOutlining = Tru
End Wit
End Su

I am not very familiar with writing code, but I did try to put this in. I changed "sheet1" to the name of my sheet and I deleted this line (.Protect Password:="hi", userinterfaceonly:=True) because I do not want a password. I think that I just want to enable the outlining. Unfortunately, I did not get this to work. I still got an error when trying to expand the tree.

Any suggestions? I don't want to have to run the macro every time I open the sheet and I am hoping for another option. If there is no other option, can anyone give me a suggestion on where I am going wrong with the code

Thanks for your time.
 
D

Dave Peterson

You can drop that password:="hi" stuff.

But you need to keep the .protect userinterfaceonly:=true stuff:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top