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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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.
 
Upvote 0
When I let run the marcro which should unhide the column,
I have to enter the password. This I want to avoid.

curti
 
Upvote 0
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"
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,554
Members
448,970
Latest member
kennimack

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