ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password Protect Sheet with formatting allowed (https://www.excelbanter.com/excel-discussion-misc-queries/247399-password-protect-sheet-formatting-allowed.html)

CER

Password Protect Sheet with formatting allowed
 
I recorded a macro (don't know enough to write one yet) to hide certain
columns, then password protect the sheet, but allow filtering, sorting, pivot
tables and formatting columns and rows. However, it doesn't check those
options when I run it. Any help is appreciated. Here's the code:

Columns("A:D").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=5
Columns("S:S").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.LargeScroll ToRight:=-2
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True,
AllowSorting:= _True, AllowFiltering:=True, AllowUsingPivotTables:=True

ActiveSheet.EnableSelection = xlNoRestrictions
ActiveSheet.Protect Password:="aaaa"

Mike H

Password Protect Sheet with formatting allowed
 
Hi,

The line where you apply the password is messing things up, Try this

Range("A:D,S:S").EntireColumn.Hidden = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:= _
True, AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowSorting:=True, AllowFiltering:=True,
AllowUsingPivotTables:=True, _
Password:="aaaa"

ActiveSheet.EnableSelection = xlNoRestrictions


Mike
"CER" wrote:

I recorded a macro (don't know enough to write one yet) to hide certain
columns, then password protect the sheet, but allow filtering, sorting, pivot
tables and formatting columns and rows. However, it doesn't check those
options when I run it. Any help is appreciated. Here's the code:

Columns("A:D").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=5
Columns("S:S").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.LargeScroll ToRight:=-2
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True,
AllowSorting:= _True, AllowFiltering:=True, AllowUsingPivotTables:=True

ActiveSheet.EnableSelection = xlNoRestrictions
ActiveSheet.Protect Password:="aaaa"


CER

Password Protect Sheet with formatting allowed
 
That worked. Thank you for the quick help.

CER

"Mike H" wrote:

Hi,

The line where you apply the password is messing things up, Try this

Range("A:D,S:S").EntireColumn.Hidden = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:= _
True, AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowSorting:=True, AllowFiltering:=True,
AllowUsingPivotTables:=True, _
Password:="aaaa"

ActiveSheet.EnableSelection = xlNoRestrictions


Mike
"CER" wrote:

I recorded a macro (don't know enough to write one yet) to hide certain
columns, then password protect the sheet, but allow filtering, sorting, pivot
tables and formatting columns and rows. However, it doesn't check those
options when I run it. Any help is appreciated. Here's the code:

Columns("A:D").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=5
Columns("S:S").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.LargeScroll ToRight:=-2
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True,
AllowSorting:= _True, AllowFiltering:=True, AllowUsingPivotTables:=True

ActiveSheet.EnableSelection = xlNoRestrictions
ActiveSheet.Protect Password:="aaaa"


Mike H

Password Protect Sheet with formatting allowed
 
Your welcome

"CER" wrote:

That worked. Thank you for the quick help.

CER

"Mike H" wrote:

Hi,

The line where you apply the password is messing things up, Try this

Range("A:D,S:S").EntireColumn.Hidden = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:= _
True, AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowSorting:=True, AllowFiltering:=True,
AllowUsingPivotTables:=True, _
Password:="aaaa"

ActiveSheet.EnableSelection = xlNoRestrictions


Mike
"CER" wrote:

I recorded a macro (don't know enough to write one yet) to hide certain
columns, then password protect the sheet, but allow filtering, sorting, pivot
tables and formatting columns and rows. However, it doesn't check those
options when I run it. Any help is appreciated. Here's the code:

Columns("A:D").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.SmallScroll ToRight:=5
Columns("S:S").Select
Selection.EntireColumn.Hidden = True
ActiveWindow.LargeScroll ToRight:=-2
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True,
AllowSorting:= _True, AllowFiltering:=True, AllowUsingPivotTables:=True

ActiveSheet.EnableSelection = xlNoRestrictions
ActiveSheet.Protect Password:="aaaa"



All times are GMT +1. The time now is 04:59 AM.

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