Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Hide columns in macro while protected

I have a macro that hides columns and another that reveals these columns. I
want to have parts of my worksheet protected. When having the worksheet
protected I cannot use the macro. I know that you can write:

ActiveSheet.Unprotect Password:="MyPassword"
Columns("D:G").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="MyPassword"

This works. The problem is if the user that has access to the password wants
to change the password but is not informed of the fact the macro has to be
changed. Is there any choice you can make when protecting the worksheet so
that columns can be hidden/revealed? They are after all not altered? I am
very greatful for any assistance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Hide columns in macro while protected

Look at the 5th argument to the .Protect method.
Your code will still run on a protect WS.

NickHK

"Sally Mae" wrote in message
...
I have a macro that hides columns and another that reveals these columns.

I
want to have parts of my worksheet protected. When having the worksheet
protected I cannot use the macro. I know that you can write:

ActiveSheet.Unprotect Password:="MyPassword"
Columns("D:G").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="MyPassword"

This works. The problem is if the user that has access to the password

wants
to change the password but is not informed of the fact the macro has to be
changed. Is there any choice you can make when protecting the worksheet so
that columns can be hidden/revealed? They are after all not altered? I am
very greatful for any assistance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Hide columns in macro while protected

thank you! I am really bad at vba so I dont really know how to work this
out...Can you please help me by being a bit more specific..Are you supposed
to set the 5th argument false..How do you write this? I am sorry i am just
completely wothless at this. Thank you very much for your help!

"NickHK" skrev:

Look at the 5th argument to the .Protect method.
Your code will still run on a protect WS.

NickHK

"Sally Mae" wrote in message
...
I have a macro that hides columns and another that reveals these columns.

I
want to have parts of my worksheet protected. When having the worksheet
protected I cannot use the macro. I know that you can write:

ActiveSheet.Unprotect Password:="MyPassword"
Columns("D:G").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="MyPassword"

This works. The problem is if the user that has access to the password

wants
to change the password but is not informed of the fact the macro has to be
changed. Is there any choice you can make when protecting the worksheet so
that columns can be hidden/revealed? They are after all not altered? I am
very greatful for any assistance




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Hide columns in macro while protected

Put the cursor in the .Protect and hit the function key F1. The Help will
explain it to you, along with the other arguments.

NickHk

"Sally Mae" wrote in message
...
thank you! I am really bad at vba so I dont really know how to work this
out...Can you please help me by being a bit more specific..Are you

supposed
to set the 5th argument false..How do you write this? I am sorry i am just
completely wothless at this. Thank you very much for your help!

"NickHK" skrev:

Look at the 5th argument to the .Protect method.
Your code will still run on a protect WS.

NickHK

"Sally Mae" wrote in message
...
I have a macro that hides columns and another that reveals these

columns.
I
want to have parts of my worksheet protected. When having the

worksheet
protected I cannot use the macro. I know that you can write:

ActiveSheet.Unprotect Password:="MyPassword"
Columns("D:G").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="MyPassword"

This works. The problem is if the user that has access to the password

wants
to change the password but is not informed of the fact the macro has

to be
changed. Is there any choice you can make when protecting the

worksheet so
that columns can be hidden/revealed? They are after all not altered? I

am
very greatful for any assistance






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hide columns in macro while protected

Nick was suggesting that you protect the sheet using the Userinterfaceonly
keyword.

Option Explicit
Sub auto_open()
With Worksheets("sheet1")
.Protect Password:="hi", userinterfaceonly:=True
End With
End Sub

It needs to be reset each time you open the workbook. (excel doesn't remember
it after closing the workbook.)

But if you're using xl2002 or higher, then you'll have to supply the password to
do this. (If I recall correctly, excel would allow you to change this setting
in xl97 and xl2k without knowing the password. But that changed with a newer
version.)

I think I'd yell at that person to not change the password!



Sally Mae wrote:

I have a macro that hides columns and another that reveals these columns. I
want to have parts of my worksheet protected. When having the worksheet
protected I cannot use the macro. I know that you can write:

ActiveSheet.Unprotect Password:="MyPassword"
Columns("D:G").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Protect Password:="MyPassword"

This works. The problem is if the user that has access to the password wants
to change the password but is not informed of the fact the macro has to be
changed. Is there any choice you can make when protecting the worksheet so
that columns can be hidden/revealed? They are after all not altered? I am
very greatful for any assistance


--

Dave Peterson


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 columns on a protected sheet Rose Excel Worksheet Functions 2 January 22nd 10 06:05 PM
hide columns on a protected sheet??? Rose Excel Discussion (Misc queries) 1 January 22nd 10 04:59 PM
Need a macro to hide certain columns Dallman Ross Excel Discussion (Misc queries) 12 October 19th 06 05:58 PM
If I have my sheets protected will that prevent me running a macro to hide certain sells? Marc Excel Worksheet Functions 0 May 17th 06 11:36 PM
Macro to hide Columns Andy Ward Excel Programming 7 May 16th 04 03:46 PM


All times are GMT +1. The time now is 12:14 PM.

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

About Us

"It's about Microsoft Excel"