Hide/Unhide columns in an protected sheet

curti

New Member
Joined
Feb 12, 2004
Messages
2
Hello together

I want to write a macro which can hide/unhide Columns in a protected sheet.

Can someone help me?
thanks and regards from Switzerland
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

earlyd

Well-known Member
Joined
Dec 10, 2002
Messages
1,199
Hi Curti,

Have your macro unprotect the sheet in the beginning and reprotect it in the end. Put your hide/unhide code in between. You can get the code by recording yourself unprotecting and reprotecting.
 

curti

New Member
Joined
Feb 12, 2004
Messages
2
When I let run the marcro which should unhide the column,
I have to enter the password. This I want to avoid.

curti
 

Wookie

Board Regular
Joined
Mar 4, 2003
Messages
220
Here is some code i use to do something similar. My password being word

Sheets("A").Select
ActiveSheet.Unprotect "word"
Cells.Select
Selection.EntireColumn.Hidden = False
Columns("N:Q").Select
Selection.EntireColumn.Hidden = True
Columns("AG:AT").Select
Selection.EntireColumn.Hidden = True
Range("A1").Select
ActiveSheet.Protect Password:="word"
 

earlyd

Well-known Member
Joined
Dec 10, 2002
Messages
1,199
Do you need a password? You can protect the sheet without one if the purpose of protection is to avoid accidentally overlaying something.

If you need one, then see last post.
 
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,152,163
Messages
5,768,555
Members
425,481
Latest member
ihumanl

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