+ Reply to Thread
Results 1 to 6 of 6

Macros in protected sheet hiding/unhiding rows & cols

  1. #1
    Registered User
    Join Date
    04-01-2009
    Location
    WashDC
    MS-Off Ver
    Excel 2003
    Posts
    84

    Macros in protected sheet hiding/unhiding rows & cols

    I have a workbook to be distributed to a bunch of people. I want it to mostly be protected/locked. However, some macros that are accessed by drop-down lists have to be able to hide columns and rows (using Custom Views for columns, and a key field for rows). Protecting it seems to break it. I haven't had time to play with it much, but any insight is appreciated.

    If you see anything else that would make it more robust, I'd really appreciate it: it sometimes crashes in some obscure way where enableevents and ScreenUpdating are both left off, and maybe other problems. It needs to be pretty tough, ideally.

    Thanks!

    Keith

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    4,991

    Re: Macros in protected sheet hiding/unhiding rows & cols

    have the macro unprotect to make the changes, and then re-protect
    Please Login or Register  to view this content.
    .unprotect to unprotect it.

    Sorry have not looked at your code for other suggestions, but thought you might like this input to start.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    04-01-2009
    Location
    WashDC
    MS-Off Ver
    Excel 2003
    Posts
    84

    Re: Macros in protected sheet hiding/unhiding rows & cols

    So my only concern about that is that if it's password protected, and it crashes in the middle of the macro, it's both left unprotected AND the password is plain-text visible in the macro, right? But if that's the only way to do it... this isn't financial information or anything, but it is sensitive data.

    K
    Last edited by keithwins; 12-19-2014 at 03:32 PM. Reason: typo

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    4,991

    Re: Macros in protected sheet hiding/unhiding rows & cols

    I might suggest reading up on error trapping. With an "onerror goto whatevername" statement, your code will go to that marker (whatevername elsewhere in the code. Often you put all the code that normally executes, and then type "exit sub" which stops the sub at that point. Then between "exit sub" and "end sub" you put whatevername: (I usuaully use the word handler for whatevername), followed by the code that would run if your error stopped normal code function. There I would re-enable events, screenupdating, and stuff like protecting sheet.

    Sorry I hope that makes some sense? If you have questions don't hesitate

    Example:

    Please Login or Register  to view this content.
    Last edited by Arkadi; 12-19-2014 at 03:28 PM.

  5. #5
    Registered User
    Join Date
    04-01-2009
    Location
    WashDC
    MS-Off Ver
    Excel 2003
    Posts
    84

    Re: Macros in protected sheet hiding/unhiding rows & cols

    Thanks Arkadi, I'd forgotten entirely about adding error trapping (I'm pretty new to VBA). That's a great idea. Do I have to add it to every subroutine that one subroutine calls? That's a really useful comment.

  6. #6
    Registered User
    Join Date
    04-01-2009
    Location
    WashDC
    MS-Off Ver
    Excel 2003
    Posts
    84

    Re: Macros in protected sheet hiding/unhiding rows & cols

    Nevermind, I see that I only need to set up one error handler, as long as I don't have context-specific things I need to do in subroutines. As I understand.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help with hiding or unhiding multiple ranges of rows based on cell value on another sheet
    By Jake Bierly in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-22-2013, 12:14 PM
  2. Faster macros for hiding/unhiding rows?
    By Teaorchid in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-22-2013, 10:24 PM
  3. Hiding/Unhiding Rows
    By marcheese in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2012, 11:56 PM
  4. Replies: 2
    Last Post: 07-28-2011, 10:41 PM
  5. Hiding rows while sheet is protected
    By burnsbyrne in forum Excel General
    Replies: 5
    Last Post: 08-22-2006, 03:40 PM

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