+ Reply to Thread
Results 1 to 5 of 5

Unprotect method fails except on step through

  1. #1
    Registered User
    Join Date
    12-15-2009
    Location
    Houston, TX, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    Question Unprotect method fails except on step through

    I have a worksheet with a linked table and with the following code in it:

    Please Login or Register  to view this content.
    It works fine on step through, but watching the code run fired from a button or from the developer menu, it never unprotects the sheet which is presumably why it fails to refresh.

    Unfortunately, I can't post the sheet because it contains a lot of sensitive data and I'm not sure how to anonymize it properly while maintaining the characteristics of the original sheet (lookups, linked tables, etc). Can any forum watchers help?
    Last edited by smokebreak; 12-06-2010 at 12:49 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Unprotect method fails except on step through

    Hello smokebreak,

    Sheets("Input") must be the active sheet when the macro is run. You probably have this sheet active when you run the debugger and that is why it is working.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-15-2009
    Location
    Houston, TX, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Unprotect method fails except on step through

    Leith, thanks for your response. However, changing the code to

    Please Login or Register  to view this content.
    Does not remedy the problem.

  4. #4
    Registered User
    Join Date
    12-15-2009
    Location
    Houston, TX, USA
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Unprotect method fails except on step through

    After some additional researching, here is what I found (in case someone else is looking for this one day).

    ActiveSheet.RefreshAll was refreshing my linked table in the background, which the protected sheet didn't like.

    Below is the code that works:

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Unprotect method fails except on step through

    Hello smokebreak,

    Thanks for sharing what you found. This is classic example of why you should post all of your code or the workbook. The refresh was a critical piece that got let out.

+ 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