Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hide unhide rows -Protected sheet Wanna Learn Excel Discussion (Misc queries) 3 August 5th 09 05:43 PM
hide ,unhide columns on protected worksheet kamlesh Excel Programming 1 January 11th 07 04:17 PM
how do i unhide password protected rows? RhondaJ Excel Discussion (Misc queries) 2 May 4th 05 12:02 AM
Password to hide and unhide sheets Veera Excel Programming 2 July 23rd 03 04:23 PM
Password to hide and unhide sheets Patrick Molloy Excel Programming 0 July 23rd 03 04:04 PM


All times are GMT +1. The time now is 11:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"