VBA Protecting a sheet to prevent unhide column but allow outlining

miless2111s

Active Member
Joined
Feb 10, 2016
Messages
273
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
2,061
Office Version
  1. 365
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,713
Messages
5,833,269
Members
430,200
Latest member
ADLHMA2022

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
Top