Outlining in Protected Sheet - Attention DP

G

Guest

I have a question about a previous code I saw for maintaining outlines in a
protected worksheet. DP, if you read this, need your help - the code was one
you posted for someone.

Before the code, your wrotes:

If you already have the outline applied, you can protect the worksheet in code
(auto_open/workbook_open??) - What does this mean?

The code is as follows:

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

At the end, you also add that it needs to be reset each time, what too does
that mean?

Two other small questions
1.) - what is the code doing exactly (I just need to understand what it says
in simple terms which helps me understand and change the code if necessary)
2.)And two, everytime I paste it, the "Option Explicit" always pastes
separately. Should I be pasting this under View code on worksheet or
somewhere else? (I admit, my programming knowledge is limited but I can
understand if it's explained)
Thanks in advance.
 
D

Dave Peterson

It means that you can't do what you want manually. You have to use code to make
it work the way you want.

And this is a setting that excel won't remember tomorrow if you set it today.
You have to reset it each time you open that file.

========
#1. It looks at Sheet1 (change that to match your sheet name). It protects the
sheet using a password--I used "hi", change it to match your password. The
..enableoutlining enables the outlining feature. The .enableautofilter will
enable you to use the filter arrows.

But both of these have to be applied before the code runs--you can't add
data|filter or Data|group with the worksheet protected. You apply those
manually (usually).

#2. This code doesn't go behind a worksheet or behind ThisWorkbook. It goes
into a general module.

Option explicit
is the way developers tell excel that they are going to be declaring every
variable that they use.

That should be used once (per module) and it should appear at the top of the
module.
 
G

Guest

Dave, you explain even technical stuff very well - THANK YOU!!!! At this
rate, I will become a programmer :) Thanks a lot, I will try and avoid doing
programming stuff coz that is how I am getting stuck, but you do explain
things so well that it is easy for non-programmer like me to figure out.
Thank you!!!!
 
D

Dave Peterson

Glad I could help.

But the best way to learn (I think) is to struggle with it. I wouldn't give
up. There's just so much more you can do with a little code that makes life
much easier.
 

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