Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Question VBA assistance needed, Grouping and Tables

I'm brand new to Macros, so bear with me. I have a workbook that will have some protected and unprotected sheets. One sheet is in a table format, where columns are grouped. Upon protecting the sheet, and attempting to expand the columns provides an error. Thus the following logic was added.

Sub Auto_Open()

Application.ScreenUpdating = False

For Each ws In Sheets
With ws
.Unprotect Password:="XXXXadmin"
.Protect Password:="XXXXadmin", UserInterfaceOnly:=True
.EnableOutlining = True
End With

Next ws

Application.ScreenUpdating = True

End Sub

Allowing me to collapse and expand columns, until I started tinkering with protected sheets and changing passwords (outside of the Macro). Now I consistently get a Run-time error '1004'. Password you supplied is not correct... Two questions - 1) does the XXXXadmin password in the Macro above have to match the sheet or workbook protection password YYYYadmin? - I've tried both and neither work 2) Can I run this subroutine just on one sheet? I don't have grouping any where else.

Any help greatly appreciated and needed!

Last edited by Coyoteman : April 4th 16 at 10:53 PM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default VBA assistance needed, Grouping and Tables

I'm brand new to Macros, so bear with me. I have a workbook that will
have some protected and unprotected sheets. One sheet is in a table
format, where columns are grouped. Upon protecting the sheet, and
attempting to expand the columns provides an error. Thus the
following logic was added.

Sub Auto_Open()

Application.ScreenUpdating = False

For Each ws In Sheets
With ws
.Unprotect Password = "XXXXadmin"
.Protect Password:="XXXXadmin", UserInterfaceOnly:=True
.EnableOutlining = True
End With

Next ws

Application.ScreenUpdating = True

End Sub

Allowing me to collapse and expand columns, until I started tinkering
with protected sheets and changing passwords (outside of the Macro).
Now I consistently get a Run-time error '1004'. Password you supplied
is not correct... Two questions - 1) does the XXXXadmin password in
the Macro above have to match the sheet or workbook protection
password YYYYadmin? - I've tried both and neither work 2) Can I run
this subroutine just on one sheet? I don't have grouping any where
else.

Any help greatly appreciated and needed!


The password used by code must be the password used to apply
protection. Also, you must reset protection each time the file is
opened because the *UserInterfaceOnly* option is not persistent.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default VBA assistance needed, Grouping and Tables

FWIW
You may want to look at my 1st reply to the topic 'VBA error 1004...'
on 3/18/2016!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
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
More Assistance Needed with Pivot Tables Michelle Excel Discussion (Misc queries) 1 August 14th 07 11:05 PM
VBA assistance - Summing by grouping Tom Excel Discussion (Misc queries) 0 March 17th 06 06:41 PM
VBA Assistance Needed RalphB Excel Discussion (Misc queries) 5 February 22nd 06 06:16 PM
Macro assistance needed HJ Excel Programming 3 November 2nd 04 10:46 PM
Assistance Needed with Comparing alexm999[_74_] Excel Programming 4 May 19th 04 10:04 PM


All times are GMT +1. The time now is 09:12 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"