+ Reply to Thread
Results 1 to 6 of 6

Made a VBA code to protect sheets... now I can't unprotect the sheets

  1. #1
    Registered User
    Join Date
    11-14-2016
    Location
    CA
    MS-Off Ver
    2016
    Posts
    12

    Made a VBA code to protect sheets... now I can't unprotect the sheets

    So I have a workbook with many sheets and wanted to protect all of the sheets using VBA. So I found some code online to do this, and it worked, but now when I try to unlock any of the sheets it says the password is incorrect...

    Here is the code...

    Please Login or Register  to view this content.
    So what is my password?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Made a VBA code to protect sheets... now I can't unprotect the sheets

    Presumably you're using 1234 as the password?

    Upload the workbook so that we can see the problem in context.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-14-2016
    Location
    CA
    MS-Off Ver
    2016
    Posts
    12

    Re: Made a VBA code to protect sheets... now I can't unprotect the sheets

    Quote Originally Posted by Richard Buttrey View Post
    Presumably you're using 1234 as the password?

    Upload the workbook so that we can see the problem in context.
    Yes, I'm using 1234. Also tried any variation I can think of.

    I cannot upload it due to it's proprietary nature. However, I've tried it in a brand new workbook and it has the same issue. You can paste the code above into a VBA module and try it out.
    Attached Files Attached Files

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Made a VBA code to protect sheets... now I can't unprotect the sheets

    That's a weird one and needs further investigation. Changing the macro to
    Please Login or Register  to view this content.
    will programatically unprotect the sheet but manually entering 1234 as the password won't! Very odd.

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Made a VBA code to protect sheets... now I can't unprotect the sheets

    Your code, as posted, has an error.... parameters use := to define their values.

    Please Login or Register  to view this content.
    The code cannot run so makes me think that is not the code you have run... Try unprotecting with a blank password.

  6. #6
    Registered User
    Join Date
    11-14-2016
    Location
    CA
    MS-Off Ver
    2016
    Posts
    12

    Re: Made a VBA code to protect sheets... now I can't unprotect the sheets

    Thanks! Glad I can finally unprotect my sheets, phew!

    However, it's strange that I can't manually unprotect the sheet by going through the Review tab.

+ 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. VBA to unprotect sheets x 2, refresh data then protect sheets
    By kaseyleigh in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-18-2016, 08:38 AM
  2. [SOLVED] Protect/Unprotect sheets
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-17-2014, 07:33 PM
  3. [SOLVED] Macro to Unprotect sheets-unlock range of cells-protect sheets
    By jrace in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2013, 10:45 AM
  4. [SOLVED] protect/unprotect all sheets
    By wayneg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-03-2012, 08:20 AM
  5. [SOLVED] Password protect and unprotect all sheets EXCEPT two named sheets
    By Ducatisto in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2012, 05:43 AM
  6. protect/unprotect all sheets
    By roos in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2006, 06:50 PM
  7. Protect/Unprotect sheets (without activating them)
    By Te4t0n in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-12-2005, 03:47 AM

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