+ Reply to Thread
Results 1 to 4 of 4

How to unlock specific cells when data is entered?

  1. #1
    Registered User
    Join Date
    07-19-2008
    Location
    UK
    Posts
    4

    How to unlock specific cells when data is entered?

    Hi there,

    I need to create a spreadsheet where I want to force the user to enter data in the right order.

    So, for example, I want cell B5 to be locked UNTIL data is entered in A3, A4 and A5, BUT for the remainder of locked cells - column C say - to stay locked.

    I recently found this answer to a similar problem:


    "The first thing you need to do is to protect the worksheet. By default all cells are "locked". Select the cell(s) you wish your user to enter data into. Right click and choose Format Cells. In the Format Cells window select the Protection tab. De-select the Locked checkbox and click OK.

    I usually fill the user data entry cell with the pale yellow color to draw the users eye to that cell(s). With the desired cell unlocked, go to the Tools menu and select Protection - Protect Sheet... You can accept the default and click OK. For this example I did not select any other attributes nor added a password.

    Open the VBA Editor (Alt+F11) and on the right in the Project-VBAProject pane locate your Workbook in the tree. Open the Microsoft Excel Objects and select your Worksheet.

    Paste this code in the code pane:

    Please Login or Register  to view this content.
    Note: change
    Please Login or Register  to view this content.
    to reflect your user cell.

    Still in the VBA Editor in the Microsoft Excel Objects for your Workbook locate ThisWorkbook. Paste this code in the code pane:

    Please Login or Register  to view this content.
    When the WB is closed it is set back to Protected.

    Save the Workbook"



    However, this turns off protection for the entire sheet once data has been entered.

    Does anyone know how to change this so that only a certain range of cells are unlocked, not eveything?


    Thanks very much for any help!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    You need to unlock the cells before you protect the sheet
    Check this out:
    http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm

  3. #3
    Registered User
    Join Date
    07-19-2008
    Location
    UK
    Posts
    4
    Quote Originally Posted by davesexcel
    You need to unlock the cells before you protect the sheet
    Check this out:
    http://www.j-walk.com/ss/excel/faqs/protectionFAQ.htm
    Thanks for your response, but I don't think you read my post clearly.

    I am aware that you have to unlock cells before you protect them.

    What I am seeking is a way to make a certain set of cells locked UNTIL data is entered in another set of cells - at which point they would become unlocked.

    However, the solution I included in my original post has the drawback of turning off protection for the entire sheet, rather than unlocking specific few cells.

    Does anyone know how to do this?

  4. #4
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Will

    The procedure is:

    1. Unprotect the sheet
    2. Unlock/lock the cell
    3. Protect the sheet

    - exactly same as if you were doing this manually.

    To do this in code for the cell A1 try:

    Please Login or Register  to view this content.
    HTH
    Martin
    Martin Short

+ 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