Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide / Unhide Columns in Password Protected w/s
Hello;
I'm trying to protect/hide the formulas on a w/s by protecting the w/s so that I may not accidentally delete or overwrite them. It works fine with the exception that the Hide & Unhide column no longer available either via Format::Column::Hide and Unhide or by a macro. The macro to hide / unhide columns produces: Run-time error '1004': "Unable to set the Hidden property of the Range class" and in the macro code: ......Range("J1:K1").Select ....Selection.EntireColumn.Hidden = True is highlighted Is there a workaround this difficulty; namely protecting the w/s formulas and still be able to Hide / Unhide columns ?? Thank you kindly. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide / Unhide Columns in Password Protected w/s
In its simplest form, you could do toggle the visibility using this macro...
Sub ToggleColumnVisibility() Me.Unprotect With Range("J:K").EntireColumn .Hidden = Not .Hidden End With Me.Protect End Sub However, the Protect method has a lot of optional arguments that allow you to customize the level of protection, so you should check it out in the help files if your protection needs to be any more than the basic default settings. Rick "monir" wrote in message ... Hello; I'm trying to protect/hide the formulas on a w/s by protecting the w/s so that I may not accidentally delete or overwrite them. It works fine with the exception that the Hide & Unhide column no longer available either via Format::Column::Hide and Unhide or by a macro. The macro to hide / unhide columns produces: Run-time error '1004': "Unable to set the Hidden property of the Range class" and in the macro code: .....Range("J1:K1").Select ...Selection.EntireColumn.Hidden = True is highlighted Is there a workaround this difficulty; namely protecting the w/s formulas and still be able to Hide / Unhide columns ?? Thank you kindly. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hide / Unhide Columns in Password Protected w/s
Rick;
Perfect! Thank you. (Obviously in your code, one must replace Me keyword with ActiveSheet in a standard macro.) Another way is suggested by schielrn and jonmo1. In the existing standard macro, add: Sub Hide_UnHide () ActiveSheet.Unprotect "Password" '... Code to hide / unhide ActiveSheet.Protect "Password" End Sub Thanks again. "Rick Rothstein (MVP - VB)" wrote: In its simplest form, you could do toggle the visibility using this macro... Sub ToggleColumnVisibility() Me.Unprotect With Range("J:K").EntireColumn .Hidden = Not .Hidden End With Me.Protect End Sub However, the Protect method has a lot of optional arguments that allow you to customize the level of protection, so you should check it out in the help files if your protection needs to be any more than the basic default settings. Rick "monir" wrote in message ... Hello; I'm trying to protect/hide the formulas on a w/s by protecting the w/s so that I may not accidentally delete or overwrite them. It works fine with the exception that the Hide & Unhide column no longer available either via Format::Column::Hide and Unhide or by a macro. The macro to hide / unhide columns produces: Run-time error '1004': "Unable to set the Hidden property of the Range class" and in the macro code: .....Range("J1:K1").Select ...Selection.EntireColumn.Hidden = True is highlighted Is there a workaround this difficulty; namely protecting the w/s formulas and still be able to Hide / Unhide columns ?? Thank you kindly. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
hide unhide rows -Protected sheet | Excel Discussion (Misc queries) | |||
hide ,unhide columns on protected worksheet | Excel Programming | |||
how do i unhide password protected rows? | Excel Discussion (Misc queries) | |||
Password to hide and unhide sheets | Excel Programming | |||
Password to hide and unhide sheets | Excel Programming |