+ Reply to Thread
Results 1 to 9 of 9

Unlock & Lock Current Sheet

  1. #1
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    205

    Unlock & Lock Current Sheet

    I need to add code to an existing macro that will first unlock the current sheet that is protected with a password of "password" and then re-lock it at the end using the same password. Thanks.

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,575

    Re: Unlock & Lock Current Sheet

    Could use a function. Then you can check whether the unlock was successful

    Please Login or Register  to view this content.
    Example Usage
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    205

    Re: Unlock & Lock Current Sheet

    Thanks but I would rather keep it in the macro. Is that possible?

  4. #4
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,575

    Re: Unlock & Lock Current Sheet

    Sure

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    205

    Re: Unlock & Lock Current Sheet

    I couldn't get that to work. Here is my current code that needs to be the "else"
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    205

    Re: Unlock & Lock Current Sheet

    Thank you for this and it worked. But I need to add something. When the sheet is protected using this code, it only allows locked and unlocked cells to be selected. I need it to allow a few other things when locked.
    1) Delete Rows
    2) Sort
    3) Use Autofilter

    Can you please help with this? Thanks.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    46,964

    Re: Unlock & Lock Current Sheet

    That's not obvious from your code. Just record a macro while you protect the sheet with the criteria you require. Then copy and paste that into your code (together with the password line).
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Contributor
    Join Date
    11-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    205

    Re: Unlock & Lock Current Sheet

    I will try that but here is the protect code.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    46,964

    Re: Unlock & Lock Current Sheet

    Have you recorded the criteria?

    Something like this:

    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)

Similar Threads

  1. Function for unlock & lock sheet with option for filters
    By Immortal2014 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2023, 03:24 PM
  2. Button to unlock and lock sheet
    By excelisland in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2020, 12:15 PM
  3. [SOLVED] Lock Picture Only - When unlock sheet temporary for clear
    By rr1050 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2016, 12:00 PM
  4. lock/unlock specific cell in a password protected sheet
    By Opi in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 03-01-2016, 04:43 AM
  5. [SOLVED] Macro to unlock sheet, copy to new workbook, then re-lock original sheet
    By Foos Master in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-08-2015, 09:16 PM
  6. [SOLVED] VBA to auto-unlock a worksheet and then re-lock that sheet
    By Foos Master in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-08-2015, 09:14 PM
  7. [SOLVED] i want to lock a tab in excel, and unlock in another sheet
    By john tempest in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-18-2005, 01:10 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