ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protect a sheet but allow columns to unhide (https://www.excelbanter.com/excel-discussion-misc-queries/199127-protect-sheet-but-allow-columns-unhide.html)

Plum

Protect a sheet but allow columns to unhide
 
Hi there,
I'm a bit stumped! I have got a sheet in Excel that needs to be protected.
However, I have grouped certain columns using the Group Outline tool which
have the "+" symbol at the top of the sheet. I would like the sheet to be
completely protected, but allow the hidden sheets to hide and unhide when the
"+" and "-" are clicked. Can anyone help?

Dave Peterson

Protect a sheet but allow columns to unhide
 
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.)

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

Plum wrote:

Hi there,
I'm a bit stumped! I have got a sheet in Excel that needs to be protected.
However, I have grouped certain columns using the Group Outline tool which
have the "+" symbol at the top of the sheet. I would like the sheet to be
completely protected, but allow the hidden sheets to hide and unhide when the
"+" and "-" are clicked. Can anyone help?


--

Dave Peterson


All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com