+ Reply to Thread
Results 1 to 9 of 9

Creating a button to lock specific cells

  1. #1
    Registered User
    Join Date
    03-21-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    4

    Creating a button to lock specific cells

    The problem I'm facing is giving me a headache.

    First of all, let me give you a brief idea of what I've done:

    I locked all the cells by "protect sheet" option, and checked the "select unlocked cells" option.

    But there's a specific cells that I want the users to fill and use, so I went to format cells - protection - unchecked the "lock" checkbox.

    Whats the problem?

    Simply, I want to create a multi buttons, each of these buttons responsible of locking specific area of cells. Its important that the users are not able to select the cells or unlock it after the button is pressed, unless they have the password I put.


    I put this code, but its not working:

    Please Login or Register  to view this content.

    thanks.
    Last edited by 6StringJazzer; 03-21-2019 at 04:42 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Creating a button to lock specific cells

    Please explain what "not working" means.
    • Does the code run?
    • Does it run but do nothing?
    • Does it produce error messages? If so, what do the messages say?
    • Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
    • Does it hang?

    I also note that you have not implemented a password, as your description mentions.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-21-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    4

    Re: Creating a button to lock specific cells

    I meant by not working, is not doing its job that I want it to do. I have put the code but it does not protect the cell after I press the button. Also, the code doesn't show any error messages.
    PS. I didn't write the code, I copy pasted it.
    Last edited by RexaZii; 03-21-2019 at 12:53 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Creating a button to lock specific cells

    This code works for me. Please attach the file that has this code.

    The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.

  5. #5
    Registered User
    Join Date
    03-21-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    4

    Re: Creating a button to lock specific cells

    I have attached an example of the excel file I'm working on.

    as you can see in the excel sheet, each area has a submit button that I want when I press it to lock the white cells with password and make users unable to select it or edit it.
    the sheet is also password protected, the password is " 123 ".

    thanks.
    Attached Files Attached Files

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Creating a button to lock specific cells

    There is no code in this file. What cells do you want to lock?

    Also, you are using merged cells which is not a good practice, and likely to cause problems in code.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Re: Creating a button to lock specific cells

    OK, I think I see what you are doing.

    This version locks the cells but allows selection.

    I redesigned your form to eliminate merged cells but it still looks the same.

  8. #8
    Registered User
    Join Date
    03-21-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    4

    Re: Creating a button to lock specific cells

    This's not what I want, but thanks for your effort though.

    What I wanted is to make the whole sheet locked for editing or selection except certain cells. and there's a button when pressed it locks those certain cells. I don't want the user to play with the format of the worksheet accept in his fill-out area, and after he finishes and press submit his area get locked so the next person to fill won't be able to edit the previous person area.

  9. #9
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: Creating a button to lock specific cells

    Do you think about something like this:

    Please Login or Register  to view this content.
    EDIT: I did not check that 6StringJazzer suggest the same (similar) solution.
    Last edited by KOKOSEK; 03-22-2019 at 09:42 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

+ 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. Button to clear and lock cells
    By Oeysbrei in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2017, 10:28 AM
  2. Lock Button that Locks Specific Cells
    By mushman1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-16-2015, 09:35 PM
  3. Button to lock cells
    By Burlinghamla in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2015, 08:40 AM
  4. Macro to lock button with specific criteria
    By tanay.vinod in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-09-2014, 11:23 PM
  5. How to lock or unclock cells using a button
    By nageshpolu in forum Excel General
    Replies: 3
    Last Post: 06-18-2014, 10:27 AM
  6. Button to copy specific cells to another sheet, lock button if cell has text
    By elmerg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2014, 02:10 AM
  7. Protect/Lock specific cells independently through button
    By Edward HS in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-04-2008, 02:47 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