+ Reply to Thread
Results 1 to 6 of 6

Lock and Unlock Sheets based on Cell values

  1. #1
    Registered User
    Join Date
    01-31-2011
    Location
    PAKISTAN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Lock and Unlock Sheets based on Cell values

    Hi All,

    I have an excel workbook in which there are three sheets, each sheet has two cells which I have named as Sheet1!Sign1, Sheet1!Sign2.... Sheet3!Sign2.

    What I intend to do is to lock the sheet whenever the signature cells are filled in for a particular sheet.

    Please Login or Register  to view this content.
    The overall intention is that when someone fills in the signature cells the sheet gets locked or protected and whenever the signs are deleted only then data can be edited

    With the code above the sheet gets protected but I want to leave the sign cells unprotected.

    Two commented lines in the code return an error

    Unable to set the locked property of range class to locked

    Can someone please help

    Thanks

    Mujahid

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lock and Unlock Sheets based on Cell values

    If you need to be able to clear Sign1 & Sign2 then those cells must always remain Unlocked irrespective of sheet protection - on which basis perhaps you want something like:

    Please Login or Register  to view this content.
    so the above will always leave Sign1 & Sign2 unlocked and will protect the sheet only where both Sign1 & Sign2 have been populated.

    modify variables / references as necessary

  3. #3
    Registered User
    Join Date
    01-31-2011
    Location
    PAKISTAN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Lock and Unlock Sheets based on Cell values

    Thanks for the reply..
    and thanks for the help.. the code works beautifully..

    Just wondering if this code can be extended to n number of sheets.

  4. #4
    Registered User
    Join Date
    01-31-2011
    Location
    PAKISTAN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Lock and Unlock Sheets based on Cell values

    I tried this and it seems to be working

    Please Login or Register  to view this content.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Lock and Unlock Sheets based on Cell values

    Quote Originally Posted by Mujahid_Sgd
    Just wondering if this code can be extended to n number of sheets.
    if "n" is determined by simply however many sheets have both Sign1 & Sign2 ranges then it might be simplest to make this requirement the pre-emptive test:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 02-01-2011 at 05:23 AM.

  6. #6
    Registered User
    Join Date
    01-31-2011
    Location
    PAKISTAN
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Lock and Unlock Sheets based on Cell values

    Can the same functionality by put in an add in so that I donot have to write the code behind everywork book.
    I actually tried saving the book as an add in and then enabled that add in but it does not work even if I change the function type to public and define Sign1 and Sign2 in the other workbook

    What am I doing wrong?

+ 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