+ Reply to Thread
Results 1 to 10 of 10

Lock range of cells until a single cell is edited

  1. #1
    Registered User
    Join Date
    05-21-2013
    Location
    London, England
    MS-Off Ver
    Office365
    Posts
    22

    Lock range of cells until a single cell is edited

    Hi All,

    Not sure if something similar is already posted, however my VBA experience is non existent.

    Please see attached file.

    What I am trying to achieve is that when the spread sheet is opened cells C8 to F17 are completely locked so that no data can be entered. When cell C2 is edited and a value entered, then cells C8 to F17 are unlocked and editable.

    This is where I am struggling, cell C2 is a predefined list using data validation. Cells C8 to F17, will either be a predefined list, date input only, number input only or free text input only all cells having data validation for these already.

    To simplify this example more, in cells C8 to C17 is a predefined list using data validation. Then when I open the spread sheet and Cell C2 is blank, I cant adjust any cells in C8 to C17. When I pick an item from cell C2, then cells C8 to C17 become active and able to select from the list for that cell.

    I believe there is no way to do this using just data validation and protection of the sheet only and requires some sort of VBA code.

    Thanks.
    Last edited by pritesh118; 09-10-2014 at 04:48 AM.

  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: Lock range of cells until a single cell is edited

    Hi,

    Cells are only locked when Sheet Protection is switched on.
    So first change the C2 protection setting to 'Unlocked'
    Then Protect the sheet.
    Now add the following Sheet change macro

    Please Login or Register  to view this content.
    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
    05-21-2013
    Location
    London, England
    MS-Off Ver
    Office365
    Posts
    22

    Re: Lock range of cells until a single cell is edited

    Thanks for the above Richard.

    However I am not sure if I have done something wrong. I set cell C2 to be unlocked and all other cells to be locked. Then I protected the sheet so that only unlocked cells (C2) can be selected. However this stopped my drop down list from working.

    Also I can enter data outside of my list, which I don't want. and when I do enter an item from my list it requests the password for the sheet which I don't want it to do.

    I want to be able to have only a specific item from a predefined list in cell C2 selected, with then the corresponding cells to become active, without needing to enter a password.

    Are you able to do the above?

  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: Lock range of cells until a single cell is edited

    Hi,

    Perhaps you'd better upload the workbook that contains actual values in the drop down cells so that we have a complete picture.

    You should not have needed to lock any cells since they are locked by default when you protect the sheet. You only need to unlock C2.

  5. #5
    Registered User
    Join Date
    05-21-2013
    Location
    London, England
    MS-Off Ver
    Office365
    Posts
    22

    Re: Lock range of cells until a single cell is edited

    Please find attached the more relevant workbook.

  6. #6
    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: Lock range of cells until a single cell is edited

    See attached.

    I'm not sure whether there is any implication in the statement "then the corresponding cells to become active, without needing to enter a password."

    I don't know what you mean by 'corresponding cells' since your original specifically mentioned making all the range C8:F17 (now c6:f15) unlocked and editable.

    I've also added code to the workbook open event that will lock C6:F15.

  7. #7
    Registered User
    Join Date
    05-21-2013
    Location
    London, England
    MS-Off Ver
    Office365
    Posts
    22

    Re: Lock range of cells until a single cell is edited

    No I can still select the cells in the table below even when there is no data in cell c2.

    I assume what I am asking for can't be done?

  8. #8
    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: Lock range of cells until a single cell is edited

    Hi,

    In that case you must be doing something different. When I open the workbook I can't click in any cell other that C2. When I select in C2 then the table of cells becomes available.

    Do you not see this behaviour?

    Are you perhaps going on from that and deleting any C2 value and expecting the table of cells to be locked? If so that is an additional requirement that wasn't mentioned in your original and hence I haven't coded.

  9. #9
    Registered User
    Join Date
    05-21-2013
    Location
    London, England
    MS-Off Ver
    Office365
    Posts
    22

    Re: Lock range of cells until a single cell is edited

    Ahh yes that maybe it. As soon as a value is entered then I would like the below table to be available. But then if the value was deleted I want the table locked again.

  10. #10
    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: Lock range of cells until a single cell is edited

    Hi,

    In that case try the attached.

    A word of caution. One of the reasons my amended code didn't originally work was because you've merged cells C2:G2. In the attached I've coded around that so that they are still merged. However be aware that most of us avoid merged cells like the plague. they just cause too many problems and they will undoubtedly trip you up at some stage.

+ 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. [SOLVED] Can you lock a cell or prevent it from being edited with a formula?
    By bryanr72 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-11-2014, 10:37 AM
  2. Replies: 1
    Last Post: 09-17-2012, 01:07 AM
  3. Lock cell from being edited or copied/pasted
    By da_sprite in forum Excel General
    Replies: 1
    Last Post: 09-09-2012, 01:10 AM
  4. Replies: 0
    Last Post: 07-19-2012, 07:31 AM
  5. pROTECT OR lOCK CELLS SO THAT THEY CANNOT BE EDITED
    By facmess1 in forum Excel General
    Replies: 1
    Last Post: 05-31-2007, 05:26 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