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
 
I don’t believe you’ve done anything wrong, but the formula uses functions that are not compatible with Excel 2013. Is that what you need…something that works on Excel 2013?
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I don’t believe you’ve done anything wrong, but the formula uses functions that are not compatible with Excel 2013. Is that what you need…something that works on Excel 2013?
I unfortunately think so. I contacted the hospital IT department and they said they aren't looking to upgrade the system either. Where would you advise that i go from here Kirk?
 
Upvote 0
I’ll have something for you soon. I’m rewriting the formulas to use functions that should work with 2013.
 
Upvote 0
Andrea, give this a try. You may want to jump into the more complex version since it will align better with your existing structure. The more complex version is shown in columns V:Y where the dropdown lists are formed for each of the four days in this working example. You will see some redundancy in the formula, which is something that happens when a quantity or an array of values is needed in multiple places. In Excel 365, this redundancy can be greatly reduced using the LET function to assign the quantity/array formula to a name, and then the name can be used in subsequent formulas. But in this case, with Excel 2013, the embedded formula needs to be repeated...so after carefully adjusting the ranges in the first part of the formula (shown below in what I refer to as the "1st messy formula"), just copy and paste it over the redundant part that appears just after SMALL(IF((

1st messy formula found within main formula:
Excel Formula:
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,"")
Fundamentally then, the single formula approach for creating the dropdown lists takes this form, which isn't too bad to follow.
=IFERROR(INDEX( 1st messy formula , SMALL(IF(( 1st messy formula <>""),ROW(INDIRECT("1:"&COUNTA($A$2:$A$10))),""),ROW($A1))),"")
As described previously, you will want to copy this across the 1st row of your dropdown list helper table so that each day's formula adjusts to the same day's range in the roster scheduling table. Then select all of the those top row cells and drag them to the bottom of the dropdown table...all the way to the bottom even if the formula begins to create blanks. This ensures that the formula is present and able to generate the complete dropdown list even if no shift codes are excluded...so the length of this dropdown table should match the length of the list found under the initial Valid Shift Codes column.

Then the roster scheduling table uses Data Validation in each column (for each day) to point to the relevant day in the helper dropdown list. I'm showing two approaches for doing the Data Validation. The simplest in shown in column Q for the data 7/4 where the entire dropdown list range is specified as the Source for the "list". The only issue with this is those blanks that appear at the bottom of the dropdown column in V9:V11 will appear as blanks at the bottom in your selection list. If you want to clean that up, you can go for the other option, shown in columns R:T where a formula is entered as the Source for the list in the Data Validation window. That formula counts the number of elements in the list and dynamically adjusts the length of the range returned to the Data Validation list. With either approach, pay attention to what is "fixed" (the $ signs) and what is relative since you will copy the cell with the data validation and then select the entire roster block where you want this invoked and perform a Paste Special > Validation...to paste the data validation rules everywhere. If done correctly, you will only have to enter the Data Validation window one time for the first cell and simply copy that validation everywhere within a common block that shares the same dropdown list table.

The other columns (G:J and L:O) represent a two-step approach, similar to what I described in an earlier post...but the single formula approach combines these same two steps into one. Let me know if you encounter any issues or have any questions.
MrExcel_20220524.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1Valid Shift CodesDay Shift CodesNight Shift CodesEFT Codes07:00 - 16:30Reduction of D,E,N Choices Based on Counts from Roster (Unique for Each Day)Elimination of Blanks for Cleaner Drop Down List Selections (also Unique for Each Day)Notional Scheduling Days on Roster SheetSingle Formula Approach to Form Drop Down List Selections (Unique for Each Day)
2DDNND7/47/57/67/77/47/57/67/77/47/57/67/77/47/57/67/7
3MWDSNCNCNCD    MWMWMWMWDMWMWMWMW
4EENSNNSNDSSMWMWMWMWOffEOffEMWNNOffEOffE
5NMWADOEEMDOffMDNDMDOffMDN
6OffDSSNADOMDADOOffNDDADOMDADOOff
7MDESSOffOffOffOffLADOLMDLADOLMD
8ADOMDMDMDMDMDPDLPDADOEDNDPDLPDADO
9LNSSADOADOADOADO PD LE PD L
10PDNutsLLLL   PDEEE   PD
11PDPDPDPD    D    
12ND
13N
14
Valid2
Cell Formulas
RangeFormula
G2G2=Roster!D2
H2:J2,W2:Y2,R2:T2,M2:O2H2=G2+1
G3:J11G3=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,"")
L2L2=Roster!D2
L3:O11L3=IFERROR(INDEX(G$3:G$11,SMALL(IF((G$3:G$11<>""),ROW(INDIRECT("1:"&COUNTA(G$3:G$11))),""),ROW(G1))),"")
V2V2=Roster!D2
V3:Y11V3=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))),"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
Q3:Q14List=V$3:V$11
R3:T14List=OFFSET(W$3,,,SUM(N(W$3:W$11<>"")),1)
 
Upvote 0
Hi Kirk,
I've populated the formula into the helper column with the result being I'm not able to view all the options in the drop drown box and have to work through 'D', 'E' and 'N'. I realize this is what the formula is telling it to do though, so its being met. Is there a way I have all options available for each day and once they have met the 2 shift capacity they are blocked out?
thanks
 
Upvote 0
I don't understand what you mean by "I'm not able to view all the options in the drop drown box and have to work through 'D', 'E' and 'N'". If you delete entries in your roster table on some day and then manually type some entries in, do you see the corresponding helper column populating correctly? And if you manually enter two D's into that roster schedule day, do you see the D disappear from the helper column?
 
Upvote 0
I don't know if you have XL2BB available where you are, but if not, can you cut and paste the formula from a few cells so that I can examine them...just let me know which cells (e.g., the upper left cell of the roster table and the upper left of the helper table that corresponds to the same day). And give one more thing a try. In the helper table, if you're not seeing it populate correctly, select the topmost formula in that column, hit F2 to go into formula editing mode, and then re-confirm the formula by entering it as an array formula by hitting Ctrl-Shift-Enter...you should see curly brackets appear around the formula in the formula bar. Then select that cell again and drag it straight down the helper column.
 
Upvote 0
So this is the view i get with just the formula entered to M3. I've then tried adding in 'D', 'E' and 'N' codes manually into the M3 helper column and its not giving me these as options when i go to the roster, just the 'D' first.

Roster Template.xlsx
KLMN
1ANUM helper comumns
212
3D
4
5
6
7
8
9
10
11
12
13
Valid
Cell Formulas
RangeFormula
M3M3=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
Formula looks fine, except change the =2 to >=2 in six places. And then you will need to select that cell and then grab (click on and hold the mouse button) the little "handle" on the lower right corner of the highlighted cell and drag it down the entire column of your helper table. This formula does not "spill" automatically the same way the dynamic array formula did with Excel 365, so you have to populate those helper column cells with the formula. When you do that you should see the last part of the formula--where you have ROW($A1)--change to $A2, $A3, etc.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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