+ Reply to Thread
Results 1 to 7 of 7

Unlocking/Locking Cells with a button

  1. #1
    Registered User
    Join Date
    10-01-2008
    Location
    Canada
    Posts
    27

    Unlocking/Locking Cells with a button

    Hi All,

    I'm basically the middle person for a spreadsheet that I'm creating.

    The process that will be used is that, I would set up the sheet every month and send it to a data entry person. Then they would send it back to me, and i would send it to certain people for approval. Once they respond with approval I then send it back to the data entry person for filing.

    I'm hoping to create a button that will "flip" a switch to to speak.

    When I send it to the data entry person the first time, I need certain cells locked and unlocked.

    When I send it to the people for approval I need the whole thing locked as well as for when I send it back to the data entry person for filing.

    I know how to do this manually, but my issue is that every time I need to send it back to the data entry person at the beginning of the month I have to go over every data entry cell and set it up so that when I lock the sheet they stay unlocked.

    So that's where the button would come in...it could even be 2 buttons...Data Entry Locking and then a full Sheet Locking...I would need each password protected too.

    Does this make any sense...hopefully it does...I've been working on this spreadsheet forever!!!

    Thanks,
    No.Solutions.
    Last edited by No.Solutions.; 10-22-2008 at 11:21 AM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    re:Unlocking/Locking Cells with a button

    Create two buttons. By default these will be CommandButton1 and CommandButton2, alse used in the code. Note that I have not used a specific password. If you do I would suggest unprotect manually and use the buttons to protect automatically.
    Please Login or Register  to view this content.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    1. Select all of the cells that need to be unlocked for the data entry person (hold down the CTRL key to select multiple non-contiguous cells).

    2. Select Insert > Name > Define from the menu, and give this range a name (i.e. DataEntryCells) and click OK.

    3. Create 2 command buttons from the Control Toolbox tool bar.

    4. Double-click the button to unlock only the certain cells for the data entry person, and copy the following code to the VBE window (change the password in quotes to your password):

    Please Login or Register  to view this content.
    5. Double-click the button to lock all cells, and copy the following code to the VBE window (change the password in quotes to your password):

    Please Login or Register  to view this content.
    For each of the two command buttons, you can right-click and select Properties to change the name, etc. Be sure to change the TakeFocusOnClick property to false for both.

    HTH

    Jason

    Edit: looks like I type too slow.

  4. #4
    Registered User
    Join Date
    10-01-2008
    Location
    Canada
    Posts
    27
    Wow thanks for the quick replies!!

    It works!

    Is there anyway though to make it so that the other people viewing the sheet cannot click the buttons? Or it prompts you for the password to unprotect the sheet.

    I'll be the only person with the password - I just don't want the people who are approving the sheet to be able to go and alter the information the data entry person put in.

    Thanks for all your help!!

  5. #5
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    On the unprotect line, delete the password and quotes. I would think you only need to do this for CommandButton1, as CommandButton2 will only lock everything.

  6. #6
    Registered User
    Join Date
    10-01-2008
    Location
    Canada
    Posts
    27
    Sweet thanks again!

    I had also found this code that worked - was found from this thread
    HTML Code: 
    Please Login or Register  to view this content.
    I'll use yours though as it seems less complicated!!!

    Thanks again!

  7. #7
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad it helped.

    Jason

+ 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