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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

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.
 

Forum statistics

Threads
1,186,164
Messages
5,956,309
Members
438,246
Latest member
Deelea

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