protection

  • Thread starter Darrell_Sarrasin via OfficeKB.com
  • Start date
D

Darrell_Sarrasin via OfficeKB.com

I have a page set up with groups
any way to use them and protection at the same time I am using 2003 excel.
 
D

Dave Peterson

If you already have the outline/subtotals/autofilter 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
'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
End With
End Sub

It needs to be reset each time you open the workbook. (Earlier versions of
excel don't remember it after closing the workbook. IIRC, xl2002+ will remember
the allow autofilter setting under tools|Protection|protect sheet, but that
won't help when you're filtering via code.)
 
D

Darrell_Sarrasin via OfficeKB.com

Hi Dave thanks for the macro. If I run it when the document is open it works
great protects everything I want protected and allows me to use the group
feature.

If I close the document thou. When i reopen it it is locking the sheet down
and not allowing me to use the groups again.

Help?

Dave said:
If you already have the outline/subtotals/autofilter 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
'.EnableAutoFilter = True
'If .FilterMode Then
' .ShowAllData
'End If
End With
End Sub

It needs to be reset each time you open the workbook. (Earlier versions of
excel don't remember it after closing the workbook. IIRC, xl2002+ will remember
the allow autofilter setting under tools|Protection|protect sheet, but that
won't help when you're filtering via code.)
 
G

Gord Dibben

Dave's code is meant to auto run when the workbook opens, not manually run
after the workbook is already open.

Did you copy/paste into a general module?


Gord Dibben MS Excel MVP

Hi Dave thanks for the macro. If I run it when the document is open it works
great protects everything I want protected and allows me to use the group
feature.

If I close the document thou. When i reopen it it is locking the sheet down
and not allowing me to use the groups again.

Help?
 
D

Darrell_Sarrasin via OfficeKB.com

thank you I was doing it in the wrong place. can I use the same code and do
more then one sheet i have two sheets one called attendance record the other
called manager

Gord said:
Dave's code is meant to auto run when the workbook opens, not manually run
after the workbook is already open.

Did you copy/paste into a general module?

Gord Dibben MS Excel MVP
Hi Dave thanks for the macro. If I run it when the document is open it works
great protects everything I want protected and allows me to use the group
[quoted text clipped - 31 lines]
 
D

Dave Peterson

Since there are only two sheets, you could do:

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

With Worksheets("manager")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

End Sub

And it's probably the easiest way if you have different passwords for each
sheet.

If you have lots of sheets that use the same password, then there are other
options.

Darrell_Sarrasin via OfficeKB.com said:
thank you I was doing it in the wrong place. can I use the same code and do
more then one sheet i have two sheets one called attendance record the other
called manager

Gord said:
Dave's code is meant to auto run when the workbook opens, not manually run
after the workbook is already open.

Did you copy/paste into a general module?

Gord Dibben MS Excel MVP
Hi Dave thanks for the macro. If I run it when the document is open it works
great protects everything I want protected and allows me to use the group
[quoted text clipped - 31 lines]
 
D

Darrell_Sarrasin via OfficeKB.com

thanks those are the only two that have a password thanks!!!

Dave said:
Since there are only two sheets, you could do:

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

With Worksheets("manager")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

End Sub

And it's probably the easiest way if you have different passwords for each
sheet.

If you have lots of sheets that use the same password, then there are other
options.
thank you I was doing it in the wrong place. can I use the same code and do
more then one sheet i have two sheets one called attendance record the other
[quoted text clipped - 16 lines]
 
D

Darrell_Sarrasin via OfficeKB.com

thanks those are the only two that have a password thanks!!!

Dave said:
Since there are only two sheets, you could do:

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

With Worksheets("manager")
.Protect Password:="hi", userinterfaceonly:=True
.EnableOutlining = True
End With

End Sub

And it's probably the easiest way if you have different passwords for each
sheet.

If you have lots of sheets that use the same password, then there are other
options.
thank you I was doing it in the wrong place. can I use the same code and do
more then one sheet i have two sheets one called attendance record the other
[quoted text clipped - 16 lines]
 
D

Darrell_Sarrasin via OfficeKB.com

Just realized this will not let me do formatting now. what is code to turn
formatting on?

Darrell_Sarrasin said:
thanks those are the only two that have a password thanks!!!
Since there are only two sheets, you could do:
[quoted text clipped - 23 lines]
 
D

Dave Peterson

There's a handful of formatting options you see when you do
Tools|protection|protect sheet.

Record a macro when you toggle the ones you want and you'll see the code you
need.

Darrell_Sarrasin via OfficeKB.com said:
Just realized this will not let me do formatting now. what is code to turn
formatting on?

Darrell_Sarrasin said:
thanks those are the only two that have a password thanks!!!
Since there are only two sheets, you could do:
[quoted text clipped - 23 lines]
 

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