+ Reply to Thread
Results 1 to 15 of 15

How do you allow hide/unhide or group/ungroup features while protected

  1. #1
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269

    unlock sheets so Macro can run

    Hi,

    We have a file that needs to be updated monthly by running macros, but the macros are being blocked by protection. I would like to put some code at the start of the macro that unlocks all sheets and then at the end locks them up again. Actually, all I really need is a macro to do just that unlock all sheets, and then another one that locks them back up again as we will need to lock and unlock at various times and it is annoying to have to do it by sheet.

    The password is "ou" I do not know if that matters.

    If this macro is possible, will it keep the selected parameters that you check when you go in an protect something?

    Thanks tons in advance.

  2. #2
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Unprotecting all sheets

    Hi

    If you use something like the following it shoud work okay

    Please Login or Register  to view this content.
    To protect when you finish use a similar macro but change unprotect to protect.

    Regards

    Jeff

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    If you protect the sheet from VBA with the UserInterfaceOnly option, you won't need to unprotect them to run the macros.

  4. #4
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by solnajeff
    Hi

    If you use something like the following it shoud work okay

    Please Login or Register  to view this content.
    To protect when you finish use a similar macro but change unprotect to protect.

    Regards

    Jeff

    TTTTTTTTTTHHHHHHHHHHHHAAAAAAAAAANNNNNNNNNNKKKKKKKKKKKKSSSSSSS!

    That is exactly what I needed, AWESOME!!

  5. #5
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by shg
    If you protect the sheet from VBA with the UserInterfaceOnly option, you won't need to unprotect them to run the macros.
    My coworkers do not understand the VBA code and so I have to provide them with buttons, but I do have one other question...

    Is there a way to protect and yet allow hide and unhide? Does not seem to be an option for that, but maybe there is a back door way to do that. Our file needs to be protected, but we have a bunch of stuff grouped so that we can hide it easily but we want to allow it to be unhidden.

  6. #6
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269

    How do you allow hide/unhide or group/ungroup features while protected

    Hi,

    I have a protected worksheet that has several lines that are grouped (hidden) that users can't unhide by cliking the +. How do you allow this wile the sheet is protected?

    Thanks.

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    don't think you can
    here's a vba code you could assign to a button
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by davesexcel
    don't think you can
    here's a vba code you could assign to a button
    Please Login or Register  to view this content.
    That is good, but I need the sheet still protected so they can't change stuff, but still allow hide unhide

  9. #9
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by shg
    If you protect the sheet from VBA with the UserInterfaceOnly option, you won't need to unprotect them to run the macros.

    You know this may work, how do you do this? I would like to be able to allow several of the options given in the list of options when you protect, but also hide and unhide (allow my people to push the + - for group and ungroup). Is there code for these options?

    Want users to be able to:
    Select both locked and unlocked cells
    format locked cells, columns, and rows,
    hide and unhide locked rows and columns (push the + - on grouped cells)
    insert hyperlinks (though that really isn't a concern, just an option they will probably never use)

    Thanks so much for any help.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Look at Help for the UserInterfaceOnly option and post back if you have further questions.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by caliskier
    My coworkers do not understand the VBA code and so I have to provide them with buttons, but I do have one other question...
    You are missing the whole point of Shg's suggestion. If you protect as he suggests macros can act on protected sheets without unprotecting them.

    See the example here

    http://www.excel-it.com/vba_examples.htm
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  12. #12
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Quote Originally Posted by shg
    Look at Help for the UserInterfaceOnly option and post back if you have further questions.

    I have found a lot of code for this, but I can't find how to specifically tell it to allow hide and unhide when protecting. I think I understand how to build it as a userInterfaceOnly, but how do you say allow hide and unhide. I found some code done in C++ or # what ever it is and it shows this...
    Please Login or Register  to view this content.
    That is what I want, the specific categories in VB that let you tell it what you want to allow.

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475
    Quote Originally Posted by caliskier
    That is good, but I need the sheet still protected so they can't change stuff, but still allow hide unhide
    What do you mean?
    This code protects the sheet.....

  14. #14
    Forum Contributor
    Join Date
    08-03-2005
    Posts
    269
    Thanks guys, I got enough information from you all to figure it out on my own. Plus some search help reading some stuff from VBNoob. Thanks to him as well.

    Here is the solution:

    Please Login or Register  to view this content.
    Thanks!!

  15. #15
    Registered User
    Join Date
    11-11-2007
    Posts
    44
    Here's a much simpler one.

    Place this code in ThisWorkbook

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1