+ Reply to Thread
Results 1 to 4 of 4

Lock cells from user data entry based on certain condition

  1. #1
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    185

    Lock cells from user data entry based on certain condition

    I am using conditional formatting to gray out certain cells based on values in some other cells. But I would also like to somehow lock those grayed out cells so that no data can be entered in those cells.

    As an example, I have table from a1 to d5. I am applying conditional formating in a1 to d5 range based on values in a7 to d11 range so that cells corresponding to zero values are grayed out in a1 to d5 range. Now I would also like to lock those cells in a1 to d5 range corresponding to which there were zero values in a7 to d11 range.

    Is it possible? If so, would appreciate any help.

    Thank you,
    Jay

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Lock cells from user data entry based on certain condition

    Hi

    without using VBA a solution could look like this: Since you already use a condition to format the cells, you can use that condition as well in data validation.

    For example, you have a cell B2 that is conditionally formatted when C8=15. You also want to lock B2 for editing when the condition applies. So, for B2 you can use the following data validation. Click Data - Validation, select custom and enter

    =IF(C8=15,AND(B2>0,B2<0),TRUE())

    If the condition is met, any entry in the cell B2 must be both smaller AND larger than zero, otherwise an error is triggered and the entry rejected. Since no entry ever is both smaller AND larger than zero, this will always result in an invalid entry, effectively locking the cell from any entry, including text.

    This may not be the perfect solution for a large and complex worksheet, but it is a quick and dirty effective solution without any programming required.

    HTH

  3. #3
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    185

    Re: Lock cells from user data entry based on certain condition

    This would be a great solution but I am actually using a Data Validation already (list option) so that user can only input few values only. I am getting a summary in separate sheet for those few values. Any other thoughts?

    Regards,

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Lock cells from user data entry based on certain condition

    There's code in this postthat locks cells, you should be able to amend it to work for you
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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