VBA Protecting a sheet to prevent unhide column but allow outlining

miless2111s

Active Member
Joined
Feb 10, 2016
Messages
279
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have some code to protect a sheet which prevents the user from un-hiding columns:
Code:
wsh.protect password:="xxx", AllowFormattingCells:=True, userinterfaceonly:=True
however i have also used in other sheets
Code:
wsh.Protect Password:="xxx", AllowFormattingCells:=True, userinterfaceonly:=True, DrawingObjects:=True 
wsh.EnableOutlining = True

I suspect the latter to was to allow the user to open and close outlining and interact with pivot tables etc (this was a while ago so I am not sure)

In the sheets protected by the latter code the users are able to un-hide columns which isn't good.

How do I allow them to interact with pivots and grouped / outlined rows and columns but NOT un-hide columns and rows?

Many thanks

Miles
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Outlining is essentially hiding and unhiding columns or rows. So with .EnableOutlining on, they can unhide columns.

Can you move the columns to another sheet? Can you move the columns way over to the right so they can't see them? You could hide formulas that reference them so they have no idea to check in column ZZ.

Just a couple thoughts
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top