Cell validation with limits and multiple formulas

sandyandy5

New Member
Joined
May 24, 2022
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Hi! First time poster disclaimer to start with!
I’m creating a nursing shift roster and wanting to limit only 2 ‘D’ shifts per day then to lock others out. I dont know what formula I should be putting into the custom cell validation to achieve this. My current formula is =SUMPRODUCT(COUNTIF(D$4:D$16, Vailid!$E$2:$E$168)).
Any help or ideas of how to make this work would be greatly appreciated!cheers
 
That's great. I'm not sure that I follow your comment about the keyboard. Are you saying that if there is, say one D left for a day, you can select the D from the dropdown with the mouse, but what?...you get an error if you manually type a D, or you try to navigate the dropdown with the keyboard?
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
That's great. I'm not sure that I follow your comment about the keyboard. Are you saying that if there is, say one D left for a day, you can select the D from the dropdown with the mouse, but what?...you get an error if you manually type a D, or you try to navigate the dropdown with the keyboard?
Yes exactly what happens an error if you manually type it even if there is one 'd' left
 
Upvote 0
I can't duplicate that. Can you confirm that the cell where you attempt to enter the "d", what does the Data Validation source formula look like? Is it pointing to the correct column in your dropdown list helper table, and have the ranges in the OFFSET formula adjusted correctly? I'm assuming that if you jump over to the helper table, you still see a "d" in the table?
 
Upvote 0
Oh...I think I see the issue. Go back to your helper table and examine the formula: When you get to this part...
SMALL(IF((IF(NOT(IF(COUNTIF(Roster!D4:$D$16,"D")
You are missing a $ sign in front of the D4, so that array was walking away from you. It should read D$4. In fact, I think you have most of those ranges fixed but they should be semi-fixed. Compare to my original formula:
=IFERROR(INDEX(IF(NOT(IF(COUNTIF(Q$3:Q$14,"D")>=2,($A$2:$A$10="D"))+IF(COUNTIF(Q$3:Q$14,"E")>=2,($A$2:$A$10="E"))+IF(COUNTIF(Q$3:Q$14,"N")>=2,($A$2:$A$10="N"))),$A$2:$A$10,""),SMALL(IF((IF(NOT(IF(COUNTIF(Q$3:Q$14,"D")>=2,($A$2:$A$10="D"))+IF(COUNTIF(Q$3:Q$14,"E")>=2,($A$2:$A$10="E"))+IF(COUNTIF(Q$3:Q$14,"N")>=2,($A$2:$A$10="N"))),$A$2:$A$10,"")<>""),ROW(INDIRECT("1:"&COUNTA($A$2:$A$10))),""),ROW($A1))),"")

Mine refer to Q$3:Q$14 and not $Q$3:$Q$14.
 
Last edited:
Upvote 0
I can't duplicate that. Can you confirm that the cell where you attempt to enter the "d", what does the Data Validation source formula look like? Is it pointing to the correct column in your dropdown list helper table, and have the ranges in the OFFSET formula adjusted correctly? I'm assuming that if you jump over to the helper table, you still see a "d" in the table?
So the data validation source formula is =OFFSET(Valid!M$3,,,SUM(N(Valid!M$3:M$19<>"")),1). What would happen if we changed the last number in this formula from 1 to a 2? would that solve it?

When i highlight the cell within the column with either the mouse or by using the arrows on the keyboard, the dropdown arrow is into the next box to the right. once selecting a shift from here it is put into the highlighted cell not the one on the right of it.
When looking at the helper table there is one remaining 'D' there when trying to enter the shift with the keyboard.
 
Upvote 0
Oh...I think I see the issue. Go back to your helper table and examine the formula: When you get to this part...
SMALL(IF((IF(NOT(IF(COUNTIF(Roster!D4:$D$16,"D")
You are missing $ signs in front of the D4, so that array was walking away from you. It should read $D$4.
mmm it doesn't like it. Error message coming up stating 'the formula it doesn't match the data validation for this cell'
 
Upvote 0
I just revised post 44, so read it again, please...I believe that is where the problem lies. Can you copy and paste again (sorry) the formula in the upper left of your helper table.
 
Upvote 0
I just revised post 44, so read it again, please...I believe that is where the problem lies. Can you copy and paste again (sorry) the formula in the upper left of your helper table.
All good, revising now
 
Upvote 0
Oh...I think I see the issue. Go back to your helper table and examine the formula: When you get to this part...
SMALL(IF((IF(NOT(IF(COUNTIF(Roster!D4:$D$16,"D")
You are missing a $ sign in front of the D4, so that array was walking away from you. It should read D$4. In fact, I think you have most of those ranges fixed but they should be semi-fixed. Compare to my original formula:
=IFERROR(INDEX(IF(NOT(IF(COUNTIF(Q$3:Q$14,"D")>=2,($A$2:$A$10="D"))+IF(COUNTIF(Q$3:Q$14,"E")>=2,($A$2:$A$10="E"))+IF(COUNTIF(Q$3:Q$14,"N")>=2,($A$2:$A$10="N"))),$A$2:$A$10,""),SMALL(IF((IF(NOT(IF(COUNTIF(Q$3:Q$14,"D")>=2,($A$2:$A$10="D"))+IF(COUNTIF(Q$3:Q$14,"E")>=2,($A$2:$A$10="E"))+IF(COUNTIF(Q$3:Q$14,"N")>=2,($A$2:$A$10="N"))),$A$2:$A$10,"")<>""),ROW(INDIRECT("1:"&COUNTA($A$2:$A$10))),""),ROW($A1))),"")

Mine refer to Q$3:Q$14 and not $Q$3:$Q$14.
Revised though the keyboard error persists in the roster sheet. I think its workable for staff to just use the mouse instead of the keyboard though. I'm just glad all the formulas will work and allow input! lol
Roster Template.xlsx
LMN
1ANUM helper comumns
212
3D
4E
5N
6OFF
7MD
8ADO
9L
10PD
11SD
12OW
13BOS
14DSN
15ESN
16NSN
17MWSN
18MHC
19MW
Valid
Cell Formulas
RangeFormula
M3:M19M3=IFERROR(INDEX(IF(NOT(IF(COUNTIF(Roster!D$4:D$16,"D")>=2,($A$2:$A$18="D"))+IF(COUNTIF(Roster!D$4:D$16,"E")>=2,($A$2:$A$18="E"))+IF(COUNTIF(Roster!D$4:D$16,"N")>=2,($A$2:$A$18="N"))),$A$2:$A$18,""),SMALL(IF((IF(NOT(IF(COUNTIF(Roster!D$4:D$16,"D")>=2,($A$2:$A$18="D"))+IF(COUNTIF(Roster!D$4:D$16,"E")>=2,($A$2:$A$18="E"))+IF(COUNTIF(Roster!D$4:D$16,"N")>=2,($A$2:$A$18="N"))),$A$2:$A$18,"")<>""),ROW(INDIRECT("1:"&COUNTA($A$2:$A$18))),""),ROW($A1))),"")
 
Upvote 0
After fixing the helper table formula, did you copy that formula across the top of the table and then pull everything down to the bottom so that the revised formula is populating the entire table? I've examined the last formula you posted and do not see any issues:
Excel Formula:
=IFERROR( INDEX(IF(NOT(
      IF( COUNTIF(Roster!D$4:D$16,"D") >=2,  ($A$2:$A$18="D") )  +
      IF( COUNTIF(Roster!D$4:D$16,"E")  >=2,  ($A$2:$A$18="E") )  +
      IF( COUNTIF(Roster!D$4:D$16,"N") >=2,  ($A$2:$A$18="N") )),
                                                                               $A$2:$A$18,""),       
  SMALL(IF((IF(NOT(
      IF( COUNTIF(Roster!D$4:D$16,"D") >=2,  ($A$2:$A$18="D") )  +
      IF( COUNTIF(Roster!D$4:D$16,"E") >=2,  ($A$2:$A$18="E") )   +
      IF( COUNTIF(Roster!D$4:D$16,"N") >=2,  ($A$2:$A$18="N") )),
                                                                              $A$2:$A$18,"")<>""), ROW(INDIRECT("1:"&COUNTA($A$2:$A$18))),""),ROW($A1))),"")
So your initial shift codes are in $A$2:$A$18, and the first day of interest in the roster table is Roster!D$4:D$16 (so staff to be scheduled are on those same rows). I'm curious what the answer to my question above is, because if you did, the only other place to look is the data validation formula.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top