+ Reply to Thread
Results 1 to 9 of 9

Locking cells based on other cells values

  1. #1
    Registered User
    Join Date
    06-07-2016
    Location
    Glasgow, Scotland
    MS-Off Ver
    Mac
    Posts
    5

    Locking cells based on other cells values

    Hi,

    I'd like a little help with a roster system I have devised.

    I have a workbook of 7 worksheets, each worksheet is a group. Within these groups there are only allowed to be 3 members of staff on day shift "d" or night shift "n".

    At the bottom of the sheet it automatically calculates how many staff are on each shift. However, I'd like the column (Each column is a day) to automatically lock if the number of of the total shift = 3.

    So this would mean two conditions, 1 for day shift and 1 for nightshift.

    Condition 1 would be:
    If the total day shift for Monday is 3, do not allow any more 'd' to be entered

    Condition 2 would be:
    If the total night shift for Monday is 3, do not allow any more 'n' to be entered

    Thank you for any help, I am pretty stuck with this.

    Screen Shot 2016-06-07 at 15.46.05.png
    Last edited by bbarnesuk; 06-07-2016 at 11:10 AM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Locking cells based on other cells values

    It would help a lot if you could post the workbook - with fictitious names, of course.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    06-07-2016
    Location
    Glasgow, Scotland
    MS-Off Ver
    Mac
    Posts
    5

    Re: Locking cells based on other cells values

    Thank you.

    I will go through it and remove all the names.

    Once I've done that I'll repost.

    Thanks

  4. #4
    Registered User
    Join Date
    06-07-2016
    Location
    Glasgow, Scotland
    MS-Off Ver
    Mac
    Posts
    5

    Re: Locking cells based on other cells values

    Workbook attached as requested. Thanks in advance.
    Attached Files Attached Files

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Locking cells based on other cells values

    Could you please remove the protection or give us the password. It's difficult to troubleshoot and verify. Thanks.

  6. #6
    Registered User
    Join Date
    06-07-2016
    Location
    Glasgow, Scotland
    MS-Off Ver
    Mac
    Posts
    5

    Re: Locking cells based on other cells values

    Sorry, reattached.

    So the sheet attached already has an 'autolock' in place, when there is any input to any cell the sheet will lock.

    The only issue there is I don't know how to turn the VBA off from there now. Would it stop it locking if you diables macros.
    Attached Files Attached Files

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Locking cells based on other cells values

    I made a copy of your page into my own workbook. It should be enough to demonstrate the principle.

    Each cell is controlled by a Data Validation. The data validation looks at one of 4 Lists: List_D_Y, List_D, List_N and List_Null. These are static named ranges defined on sheet 2.

    There is a helper row (row 17), that has the formula: =IF(AND(D15<3,D16<3),0,IF(AND(D15<3,D16=3),1,IF(AND(D15=3,D16<3),2,3))).

    This evaluates to 0 if both day and night shifts are less than 3, 1 if day is less than 3 but night is 3, 2 if day is 3 and night is less than 3 and 3 otherwise (both day and night are three).

    The data validation on each cell is a list type that reads this range: =OFFSET(List_D_N,0,D$17) where D17 is the helper cell. So the range that is read is offset by zero if D17 is zero (meaning it reads range List_D_N), by 1 if D17 is 1 (days are available so it reads List_D) and so on.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-07-2016
    Location
    Glasgow, Scotland
    MS-Off Ver
    Mac
    Posts
    5

    Re: Locking cells based on other cells values

    Thank you very much.

    There are just a few things, probably because I'm more of a beginner with excel than anything.

    There are other values I need to use 'DR' which is a day request, and 'NR' which is a night request but should still be treated as the same D or N. Following the principle would I just entere these into Sheet 2?

    Also, I can't see any formula, do I need to in order to put it into every sheet on every row?

    Again, I'm sorry for all the question.

  9. #9
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Locking cells based on other cells values

    Yes you can enter them to the lists on Sheet 2. However go to the name manager and extend the range of the lists. Actually only List_D_N needs to be extended. The other ranges aren't really used. Rather the offset from List _D_N is used.

    You should also adjust the formulas in rows 15 and 16 to count NR against D and N.

    In Cell D4 there is a data validation, set up as shown in the picture. You can copy -> paste special / validations to the other cells on the sheets.
    Attached Images Attached Images

+ 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] Locking cells based on color in doc with merged cells
    By mushedpotatos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2014, 03:14 AM
  2. locking values for referenced cells.
    By 13lack13lade in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-20-2014, 02:23 AM
  3. Locking cells based on the value of other cells
    By aaronp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2013, 12:22 AM
  4. Locking specific cells eventually changing to locking all cells
    By davidingilbert in forum Excel General
    Replies: 1
    Last Post: 03-19-2013, 06:50 PM
  5. Locking cells based on other cell value
    By smalls in forum Excel General
    Replies: 5
    Last Post: 08-20-2010, 07:30 PM
  6. Locking a Range of Cells Based on Other Cell Values
    By _Ryan_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2010, 06:59 PM
  7. Locking cells based on value
    By Danno in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2005, 12:49 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