+ Reply to Thread
Results 1 to 6 of 6

Macro to unprotect then reprotect sheet only works once

  1. #1
    Registered User
    Join Date
    12-29-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    3

    Macro to unprotect then reprotect sheet only works once

    This macro is supposed to start by unlocking the protected sheet named "RANKER", then format and organize my ranker, and end by re-protecting that same sheet. As you might have guessed by the fact that I'm writing this, there is a problem. The macro works fine except for one thing: When I paste in my next set of info after the macro runs successfully (the next time I want to run a ranker), When I go to past my data into Q6:Q14, I get an error stating that the sheet is password protected; even though I have what I assumed was a working protect/unprotect system at the beginning and end of my macro. To clarify, when I initially open this spreadsheet, paste in my info, and run the macro, it runs perfectly by unlocking the sheet then relocking it. However when I attempt to run it again, it's almost as if my unprotect line is no longer effective. Think of it this way, it's as if my unprotect/protect lines are only good for 1 single use, and then stop working. Any help would be greatly appreciated.

    Please Login or Register  to view this content.
    Moderators Note: Please follow Forum Rule #3 and use code tags. Added this time, but please use them in the future…Thanks.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to unprotect then reprotect sheet only works once

    Some of your references are ActiveSheet and ActiveCell. If the ActiveSheet is protected and it is not Ranker, you will get an error.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro to unprotect then reprotect sheet only works once

    Try this (not tested).

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-29-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to unprotect then reprotect sheet only works once

    Hmmm...getting a compile error toward the end.

  5. #5
    Registered User
    Join Date
    12-29-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro to unprotect then reprotect sheet only works once

    Thanks. Yeah, that's the strange part. ActiveSheet is in fact Ranker. Should I just change from ActiveSheet and just name the sheet?

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to unprotect then reprotect sheet only works once

    Also see if you don't perhaps have Sheets("Ranker") protection in any other Code of your Project, for instance, Sheet Activate() etc.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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